Hi,

I need some help from u all.In a table i created 2 fields one is name and second one is age.I stored all the name data into database.In that field i want to show all name one by one in drop down box.Can anyone tell me how to do this.can anyone send code for this

thanks
Punithapary

//your database connections...
<select name="state" class="input_form" style="width:150" >
                      <option value="" selected>Select State</option>
                      <?

$query1=mysql_query("SELECT * FROM onetable ");
$cnt=mysql_num_rows($query1);
if($cnt>0)
{ 
while($list1=mysql_fetch_array($query1))
{
echo "<option value='$list1[id]' >$list1[name]</option>";
}
}
?>
                    </select>

Try something like this:

<select name="name" id="name" />
<?php
$Nms = mysql_query("SELECT name FROM db order BY name ASC");
while ($cat = mysql_fetch_array($Nms))
{
$Name= $cat["name"];
echo ("<option value=\"$Name\">$Name</option>\n");
}
?>
</select>

you can also try like this

<select name="selcategory"  id="selcategory">
                          <option value="">------Selectcategory-------</option>
                          <?
					$qry4="SELECT * FROM tbl_categories WHERE parentid=0";
					$res4=mysql_query($qry4) or die(mysql_error());
					$num4=mysql_num_rows($res4);
					if($num4>0)
					{
					while($row4=mysql_fetch_array($res4))
					{
					?>
                          <option value="<?=$row4['c_id']?>" <? if ((isset($_GET['c_id']))&&($row4['c_id']==$category)){?>selected<? }?>>
                            <?=$row4['c_name']?>
                            </option>
                          <?
					  }
					  }
					 ?>
                        </select>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.