Dear J.R.,
> I'm using win2000, php4, apache, and mysql. Using the example from chap12
Address database example from Prof php Programming. I've modified the code
in the common.php file this way (this question pertains to the
printf("Sales...) line:
> [big snip]
> This works great (writes to db) however, I can't get the script to display
the chosen option (i.e. 5-10 or whatever) when it calls the modify.php file.
It just defaults to the first blank option. Does anyone have any ideas or is
this question too vague? TIA
I use the follwing to obtain the effect you want:
<select name="new_index">
<?php
for ($i=1; $i <= $last_record; $i++) {
echo("<OPTION");
if ($current_record == $i) {
echo(" SELECTED");
}
echo(">" . $i . "</OPTION>\n");
}
?>
</select>
As you can see the if statement checks the condition (in my case
$current_record must be equal to $i) and if it is true add the word selected
to the <OPTION> tag.
Hope this helps
Ciao
Andrea