redpedia Posted March 19, 2010 Share Posted March 19, 2010 Hello , i have a strange problem i am trying to populate a combo box from mysql database, here is the code <?php include("functions.php"); mysql_connection(); $sql_query= mysql_query("select category_id,category_name from categories"); ?> <select name="category" id="category"> <option value="Choose">Choose</option> <? while($fetch= mysql_fetch_array($sql_query)) { ; ?> <option value= " <? $fetch[category_id]; ?> " selected="selected"><? $fetch[category_name]; ?> </option> <? } ?> </select> there is no errors but it keeps showing blank records or spaces inside the combo box, i mean i have 3 records now in the table , the combo box just retrieve blank 3 spaces ! , where is the problem please ? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/195838-combo-box-keeps-show-empty-records-help/ Share on other sites More sharing options...
schilly Posted March 19, 2010 Share Posted March 19, 2010 while($fetch= mysql_fetch_array($sql_query)) { ; ?> semicolon shouldn't be there. Quote Link to comment https://forums.phpfreaks.com/topic/195838-combo-box-keeps-show-empty-records-help/#findComment-1028718 Share on other sites More sharing options...
redpedia Posted March 19, 2010 Author Share Posted March 19, 2010 ok i remove it but the problem still remains .... Quote Link to comment https://forums.phpfreaks.com/topic/195838-combo-box-keeps-show-empty-records-help/#findComment-1028719 Share on other sites More sharing options...
PFMaBiSmAd Posted March 19, 2010 Share Posted March 19, 2010 You must actually echo values out from php code if you want them to be output to the browser. You should also use full opening php tags <?php Quote Link to comment https://forums.phpfreaks.com/topic/195838-combo-box-keeps-show-empty-records-help/#findComment-1028720 Share on other sites More sharing options...
redpedia Posted March 19, 2010 Author Share Posted March 19, 2010 You must actually echo values out from php code if you want them to be output to the browser. You should also use full opening php tags <?php Thank you very much , it worked now , the problem was that i forgot echo(s) ... i am a noob ! Quote Link to comment https://forums.phpfreaks.com/topic/195838-combo-box-keeps-show-empty-records-help/#findComment-1028723 Share on other sites More sharing options...
schilly Posted March 19, 2010 Share Posted March 19, 2010 haha wow. can't believe i didn't pick that up. Quote Link to comment https://forums.phpfreaks.com/topic/195838-combo-box-keeps-show-empty-records-help/#findComment-1028727 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.