Set Default Option List
Posted: Mon May 03, 2010 5:23 am
I want to display default/selected list(from database), is that possible.
All I know to display default item from option list is like this, as far as I know, tell me if Im wrong.
All I know to display default item from option list is like this, as far as I know, tell me if Im wrong.
Code: Select all
<select name="category">
<option value="cat_id">1</option>
<option value="cat_id" select>2</option>
<option value="cat_id">3</option>
</select>
Code: Select all
function cat(){
echo "<select name=\"prod_cat\">";
$onk = mysql_query("SELECT * FROM cat")or die("Error");
while($result=mysql_fetch_array($onk))
{
echo ("<option value=$result[cat_id] selected=\"$qprod[prod_cat]\">$result[cat_name]</option>");
}
echo "</select>";
}