1
I have a dropdown "select" in a form that was filled in from a DB. I'm trying to read the selected value. I can't seem to figure this out. Can someone please assist me?
Loading the dropdown works fine:
$results = $xoopsDB->query("SELECT `types_title` FROM ". XOOPS_DB_PREFIX ."_dar_types");
$select_str = "";
while ($opt = $xoopsDB->fetchArray($results)) {
$sel = $opt['types_title'];
$select_str .= "<OPTION VALUE=> $sel</OPTION>\n";
}
echo "<form action='index.php' method='post'>
<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td class='bg2'>
<table width='100%' border='0' cellpadding='4' cellspacing='1'>";
// "select_str" are the "option values" for the select gadget
echo "
<tr><td nowrap='nowrap' class='bg3'>"._XD_SELTITLE." </td><td class='bg1'><SELECT name='selection[]' size='1'> $select_str</SELECT>
<input type='submit' name='editcontents' value='"._SUBMIT."' />
<input type='hidden' name='op' value='listcontents' />
<input type='hidden' name='stage' value='2' />
<input type='hidden' name='cat_id' value='".$cat_id."' /></td>";
Notice I set the stage to 2 and when the submit button is pressed it reruns the same code which tries to extract the value of the dropdown but I can't seem to get the syntax correct...
if($stage == 2) {
$res = $_POST['selection']; <=== won't read the selection...
echo $_POST['selection'];
echo "<tr><td nowrap='nowrap' class='bg3'>"._XD_TITLE." </td>
<td class='bg1'><input type='text' name='contents_title' value='$selection' size='52' maxlength='255' /></td></tr>";
}
else {
echo "<tr><td nowrap='nowrap' class='bg3'>"._XD_TITLE." </td>
<td class='bg1'><input type='text' name='contents_title' value='$selection' size='52' maxlength='255' /></td></tr>";
}
Any help is greatly appreciated...
Thanks
Doug P