fareedreg Posted December 29, 2009 Share Posted December 29, 2009 can anyone please help me out by telling me the process of filling combobox with values from database field. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/ Share on other sites More sharing options...
premiso Posted December 29, 2009 Share Posted December 29, 2009 Using Google keywords php combo box mysql would have yielded a tutorial: http://www.internaldrive.com/2009/03/31/populating-a-combo-box-in-php-dynamically-from-mysql/ Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985580 Share on other sites More sharing options...
iPixel Posted December 29, 2009 Share Posted December 29, 2009 Here's the logic behind it, assuming you'd know how to code it. <?php >> SELECT info FROM database ?> <select name="x" id="x"> <?php while(result = mysq_fetch_assoc($sql)) { echo "<option value='value'>text</option>"; } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985586 Share on other sites More sharing options...
fareedreg Posted December 29, 2009 Author Share Posted December 29, 2009 Thanks friend but can i also fix this combo box to a particular location in my code. Here's the logic behind it, assuming you'd know how to code it. <?php >> SELECT info FROM database ?> <select name="x" id="x"> <?php while(result = mysq_fetch_assoc($sql)) { echo "<option value='value'>text</option>"; } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985618 Share on other sites More sharing options...
iPixel Posted December 29, 2009 Share Posted December 29, 2009 Yea simply by placing that code snippet directly where you want the box to show up Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985623 Share on other sites More sharing options...
fareedreg Posted December 29, 2009 Author Share Posted December 29, 2009 this my html code ,, I want it after MemberID. thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style4 {font-size: 36px} .para { width: auto; } body,td,th { font-size: 14px; } --> </style> </head> <body> <div align="center"><img src="images/libimage.jpg" width="998" height="103" /></div> <p> </p> <table width="572" height="61" align="center"> <tr> <td align="center" valign="middle"><p class="style4">MEMBER SEARCH</p> <p><a href="index.html"><img src="images/mainmenu.gif" width="128" height="40" /></a><span class="style4"><a href="membermaster.html"><a href="membermaster.html"><img src="images/return.gif" width="128" height="40" /></a></span></p></td> </tr> </table> <p> </p> <form name="memmaster" method="post" action="memmodify.php"> <table width="259" border="0" align="center"> <tr> <td width="105">Member Id</td> <td width="144"> </td> </tr> </table> <p> </p> <table width="129" border="0" align="center"> <tr> <td width="66"><input name="cmdsubmit" type="submit" id="cmdsubmit" value="Search" /></td> <td width="53"><input type="reset" name="cmdclear" id="cmdclear" value="Clear" /></td> </tr> </table> <p> </p> <p> </p> <p> </p> </body> </html> Yea simply by placing that code snippet directly where you want the box to show up Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985629 Share on other sites More sharing options...
fareedreg Posted December 29, 2009 Author Share Posted December 29, 2009 current i m doing <?php include('connect.php'); $Tb = "mem_master"; mysql_select_db($Db, $link); $query = "select mem_id from mem_master order by mem_id"; $result= mysql_query($query,$link); $fel=mysql_num_fields($result); $nro=mysql_num_rows($result); if ($nro>0) { echo "<select name='item'>\n"; echo "<option>-- Select Item --</option>\n"; while ($row=mysql_fetch_array($result)) { echo "<option value='$row[item]'>$row[mem_id]</option>\n"; } } mysql_close($link); ?> but in this method box appear some where else Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985631 Share on other sites More sharing options...
iPixel Posted December 29, 2009 Share Posted December 29, 2009 <tr> <td width="105">Member Id</td> <td width="144">PLACE YOUR PHP CODE RIGHT HERE</td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985658 Share on other sites More sharing options...
fareedreg Posted December 30, 2009 Author Share Posted December 30, 2009 OH MY GOD.. A VERY VERY HELPFULL TECHNIQUE.. THANKS A LOT DEAR... <tr> <td width="105">Member Id</td> <td width="144">PLACE YOUR PHP CODE RIGHT HERE</td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985813 Share on other sites More sharing options...
fareedreg Posted December 30, 2009 Author Share Posted December 30, 2009 One more thing dear .. how can we call onblur onchange event of ajax from this type of combo. <tr> <td width="105">Member Id</td> <td width="144">PLACE YOUR PHP CODE RIGHT HERE</td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/186605-how-to-fill-combo-box/#findComment-985816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.