Jump to content

Combo box keeps show empty records ! help


redpedia

Recommended Posts

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]

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.