Tuesday, 10 September 2013

Can I use this variable as an input value?

Can I use this variable as an input value?

I am a beginner in PHP and MySQL. Please help me solve this problem.
-----product.php------
<html>
<form action="compare.php" method="post">
<input type="submit" name="submit" value="compare" />
<?
$sql= mysql_query ("select * from table");
while ($row = mysql_fetch_object ($sql1) )
{
$id=$row->id;
$brand=$row->brand;
$seri=$row->seri;
$detail=$row->detail;
echo "<div class=product>
$brand $seri <br/>$detail
compare<input type=checkbox name=compare value=$id></div>";
} ?></html>
-----compare.php-----
<?
$a=($_POST[compare]) ;
echo "$a";
?>
When I checked some check box in product.php and clicked the compare
button, compare.php only shows the last id($id).

No comments:

Post a Comment