catching a variable in a include file
Moderator: General Moderators
catching a variable in a include file
Hello i have a tricky problem
i have a form which when filled sends the users to a confirm page, One of the elements is a dropdownlist, what i want is for the confirm drop down list to display the information from the first drop down list. Now this DDL is an include file which i put in my form.
this is the first one from the first form, this code is in an include file which is inserted into the form
$sql = "SELECT catID, catName
FROM $table_name
ORDER BY catID";
$result = @mysql_query($sql, $connection) or die("Error3 - Couldn't connect - please try later.");
while($row = @mysql_fetch_array($result))
{ //start while
$row
$catID = $row['catID'];
$catName = $row['catName'];
$option_block .= "<option value='$catID'>$catName</option>";
} //end while
$display_block = "<select name='$catID'><option>Choose an Industry</option>$option_block<option value='O'>Other</option></select>";
?>
<? echo "$display_block"; ?>
and it works fine, this is what i have down to try to catch it on the confirm page, but it doesn't work. i want to give the user the option to modify their category here
$id = '$_REQUEST[catID]';
$sql = "SELECT catID, catName
FROM $table_name
ORDER BY catID";
$result = @mysql_query($sql, $connection) or die("Error3 - Couldn't connect - please try later.");
while($row = @mysql_fetch_array($result))
{ //start while
$row
$catID = $row['catID'];
$catName = $row['catName'];
$option_block .= "<option value='$catID'>$catName</option>";
} //end while
$display_block = "<select name='$catID'><option>Choose an Industry</option><option value="$id">$catName</option>$option_block<option value='O'>Other</option></select>";
?>
<? echo "$display_block"; ?>
any help would be appreciated
i have a form which when filled sends the users to a confirm page, One of the elements is a dropdownlist, what i want is for the confirm drop down list to display the information from the first drop down list. Now this DDL is an include file which i put in my form.
this is the first one from the first form, this code is in an include file which is inserted into the form
$sql = "SELECT catID, catName
FROM $table_name
ORDER BY catID";
$result = @mysql_query($sql, $connection) or die("Error3 - Couldn't connect - please try later.");
while($row = @mysql_fetch_array($result))
{ //start while
$row
$catID = $row['catID'];
$catName = $row['catName'];
$option_block .= "<option value='$catID'>$catName</option>";
} //end while
$display_block = "<select name='$catID'><option>Choose an Industry</option>$option_block<option value='O'>Other</option></select>";
?>
<? echo "$display_block"; ?>
and it works fine, this is what i have down to try to catch it on the confirm page, but it doesn't work. i want to give the user the option to modify their category here
$id = '$_REQUEST[catID]';
$sql = "SELECT catID, catName
FROM $table_name
ORDER BY catID";
$result = @mysql_query($sql, $connection) or die("Error3 - Couldn't connect - please try later.");
while($row = @mysql_fetch_array($result))
{ //start while
$row
$catID = $row['catID'];
$catName = $row['catName'];
$option_block .= "<option value='$catID'>$catName</option>";
} //end while
$display_block = "<select name='$catID'><option>Choose an Industry</option><option value="$id">$catName</option>$option_block<option value='O'>Other</option></select>";
?>
<? echo "$display_block"; ?>
any help would be appreciated
ok, this might be what you want.
Code: Select all
$id = '$_POST[catID]';
$sql = "SELECT catID, catName
FROM $table_name
ORDER BY catID";
$result = @mysql_query($sql, $connection) or die("Error3 - Couldn't connect - please try later.");
while($row = @mysql_fetch_array($result))
{ //start while
$row
$catID = $row['catID'];
$catName = $row['catName'];
if ($catID == $id) {
$option_block .= "<option value='$catID' selected='selected'>$catName</option>";
}
else {
$option_block .= "<option value='$catID'>$catName</option>";
}
} //end while
$display_block = "<select name='$catID'><option>Choose an Industry</option><option value="$id">$catName</option>$option_block<option value='O'>Other</option></select>";
?>
<? echo "$display_block"; ?>