...

View Full Version : easy way to select a field from sql using PHP



emjez15
12-14-2010, 02:25 PM
Is there an easy way to select a field from a combox(select field) from MYSQL using PHP?
It can be in Ajax.

Coz' i want to create an edit form, so when it loads, it selects the current index from my sql database.


My current idea is to create a variable for each index for example:
<select>
<option <?php echo $select1; ?> value = 1>Choice 1</option>
<option <?php echo $select2; ?> value = 2>Choice 2</option>
<option <?php echo $select3; ?> value = 3>Choice 3</option>
</select>

But what if I looped the <select> for date purposes.

abduraooft
12-14-2010, 02:41 PM
Coz' i want to create an edit form, so when it loads, it selects the current index from my sql database. Make an if condition inside the loop to add an extra attribute to the required option, like selected="selected"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum