I know how to pass variables from a form and even store'em in a session or whatever...
I have a list box with some options in it displayed there after a select query in the database. When a user submits the form I transfer him at a new page with a preview of what's going to be inserted in the database and I have the submit form below the result he's seeing to do some editing if he did something wrong.
Variables through text boxes and text area and passed normally and can be viewed (if I use the $$variable ($variable$variable) and not the $variable), but variables from the list box are passed but I can't pass the selected variable's name. Here's what I mean:
passes only text box and text area variables not list box
$query = mysql_query("select * from categories") or die (mysql_error());
while($row = mysql_fetch_array($query))
{
if($row['cat_id'] == ltrim(rtrim($_POST['cat_id'])) && $row['cat_name'] == ltrim(rtrim($_POST['cat_name'])))
{
echo "<option selected value=\"{$_POST['cat_id']}\">{$_POST['cat_name']}</option>\n";
}
else
{
echo "<option value=\"{$row['cat_id']}\">{$row['cat_name']}</option>\n";
}
}
passes all variables from all the form elements including the list box except $row['cat_name']
$query = mysql_query("select * from categories") or die (mysql_error());
while($row = mysql_fetch_array($query))
{
if($row['cat_id'] == ltrim(rtrim($_POST['cat_id'])) && $$row['cat_name'] == ltrim(rtrim($_POST['cat_name'])))
{
echo "<option selected value=\"{$_POST['cat_id']}\">{$_POST['cat_name']}</option>\n";
}
else
{
echo "<option value=\"{$row['cat_id']}\">{$row['cat_name']}</option>\n";
}
}