Jump to content

Dynamic Drop Down List


TomT

Recommended Posts

Hi

I'm pulling some data from a DB and presenting it in a drop down list:

<option> 1 </option>

<option> 2 </option>

<option> 3 </option>

Etc..

 

This works well.

 

I decided to set one of the options as Selected using:

 

if ($user===$id) { 
echo "<option selected";
} else {
echo "<option";
}
echo " value='$id'>$name</option>";

 

This works but is VERY slow.. presumably as it has to check each $user against each $id..

 

Any way to do this faster ??

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/176816-dynamic-drop-down-list/
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.