Jump to content

need help


salhzmzm

Recommended Posts

hi

 

in my page there is this code:

 

<select name="select_one" onchang="form1.submit()">
<option value="select">please select</option>
<?php
$row=mysql_query("select * from mytable order by id");
while ($rows=mysql_fetch_array($row)) {
echo "<option value=$rows[id]>$rows[product]</option>;
}
?>

 

when the user is select the page submits and every thing apear ok, but I want the option that user had select it be the selected.

I have problem the it the selected always the first option.

 

so please help me.

 

thanks.

Link to comment
https://forums.phpfreaks.com/topic/90869-need-help/
Share on other sites

<select name="select_one" onchang="form1.submit()">
<option value="select">please select</option>
<?php
$row=mysql_query("select * from mytable order by id");
while ($rows=mysql_fetch_array($row)) {
echo "<option value=$rows[id]";
if($current_user_id == "$rows['id'])
{
    echo "selected=\"selected\"";
}
echo ">$rows[product]</option>;
}
?>

 

 

note: I didn't fix your syntax errors.

Link to comment
https://forums.phpfreaks.com/topic/90869-need-help/#findComment-465696
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.