$_POST[''] variable question
Posted: Fri Jun 03, 2005 11:31 am
Hi,
I got the following code:
it calls this function:
It all works fine except for the "if" that is supposed to mark the current value of the option's variable "selected".
index is the name of the option tag and results in the $_POST['name'] variable. It does not work, though. Putting it like this does work either.
Thanks for your help.
I got the following code:
Code: Select all
pulldown(employee,pulldown_l,getContacts(employee,name),k_nr,firstname,name);Code: Select all
function pulldown($name, $style, $source, $index, $value1, $value2, $value3)
{
$index_array=array();
$value1_array=array();
$value2_array=array();
$value3_array=array();
while($row=@mysql_fetch_array($source))
{
array_push($index_array,$row[$index]);
array_push($value1_array,$row[$value1]);
array_push($value2_array,$row[$value2]);
array_push($value3_array,$row[$value3]);
}
echo '<select name="' . $index . '" size="1" class="' . $style . '">';
echo '<option>' . $name . '</option>';
echo '<option disabled></option>';
for($i=0;$i<count($index_array);$i++)
{
echo '<option value="' . $index_array[$i] . '"';
if ($_POST[$index]==$index_array[$i]) { echo ' selected="selected"'; }
echo '>';
echo $value1_array[$i] . ' ' . $value2_array[$i] . ' ' . $value3_array[$i] . '</option>';
}
echo '</select>';
}Code: Select all
if ($_POST[$index]==$index_array[$i]) { echo ' selected="selected"'; }Code: Select all
$_POST['$index']Thanks for your help.