0

Hi!,
I have a contacts table in MySQL and I want output in a select menu.
Problem is, some rows dont have any record in it, and it is displayed in very odd way as it outputs blank fields and some data in between.

My overall code is:

<?PHP
$query=mysql_query("SELECT * FROM call_details WHERE !ISNULL(call_project_name)");
echo "<select name='detailr'>";
while($row=mysql_fetch_array($query))
{
echo "<option value=$row[call_id]>
$row[call_project_name]</option>";
}
echo "</select>";
?>

Please help me out in this matter :(

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by pritaeas
0

Hi,
try the below code, you will got it.

<?PHP

$query = mysql_query("SELECT * FROM call_details WHERE !ISNULL(call_project_name)");

echo "<select name='detailr'>";

while($row=mysql_fetch_array($query))
{
    if ($row['call_project_name'] != " "){
       echo "<option value =". $row['call_id'].">".
       $row['call_project_name']."</option>";
    }
}
echo "</select>";
?>

Edited by karteek.vemula: n/a

0

Try this.

<?PHP
$query=mysql_query("SELECT * FROM call_details WHERE !ISNULL(call_project_name)");
echo "<select name='detailr'>";
while($row=mysql_fetch_array($query))
{
echo "<option value='$row[call_id]'>".$row."</option>";
}
echo "</select>";
?>

0
$query = mysql_query("SELECT * FROM call_details WHERE !ISNULL(call_project_name)");
echo "<select name='detailr'>";
while($row = mysql_fetch_array($query))
{
   if (!empty(trim($row['call_project_name'])))
   {
      echo "<option value='{$row['call_id']}'>{$row['call_project_name']}</option>";
   }
}
echo "</select>";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.