How to pass more than one row to another page
Posted: Wed Dec 29, 2010 10:49 am
Hi,
I have a select box where I show the names of each category and I want to pass the id of the selected category to my script.php page. The problem is that $id_category gets only the id of the last category on my database. I know that this happens due to the while loop. I just don't know how to fix the situation.
Any ideas?
Thanks in advance.
I have a select box where I show the names of each category and I want to pass the id of the selected category to my script.php page. The problem is that $id_category gets only the id of the last category on my database. I know that this happens due to the while loop. I just don't know how to fix the situation.
Any ideas?
Code: Select all
<form method="POST" action="script.php">
<?php
echo "<select>";
while ($row = mysql_fetch_assoc($result)) {
echo "<option>" . $row['name'] ."</option>";
$id_category= $row["id_category"];
}
echo "</select>";
echo "<input type=\"hidden\" name=\"id_category\" value=\"$id_category\" />";
echo "<input type=\"submit\" value=\"Submit\">";
?>
Thanks in advance.