Jump to content

Query Problem, Doesnt Bring Listings Other Column


madness69

Recommended Posts

Hello there, i have a table called "category" that haves 2 columns, that are "category" and "category_en"

 

And im echo the list of data that i have, i can make the listins of columns "category appear but not the data of category_en .

Take a look in my code please

 

 


$qry=mysql_query("SELECT * FROM category", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}


<?php
while($row=mysql_fetch_array($qry))
{
echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>";
}
?>
<?php
while($row=mysql_fetch_array($qry))
{
echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>";
}
?>

Link to comment
Share on other sites


$qry=mysql_query("SELECT * FROM category", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}


<?php
while($row=mysql_fetch_array($qry))
{
echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>";
}
?>
<?php
while($row=mysql_fetch_array($qry))
{
echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>";
}
?>

 

First off, I wouldn't stop and start the <?php?> tags for one command. Just write it all inside the same tags. Also, make your query its own variable. Just to clean up the code I would do the following:

 

$get = "SELECT * FROM category";
$qry=mysql_query($get, $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
while($row=mysql_fetch_array($qry))
{
$x = $row['category_en'];
echo "<option value='$x'>''$x</option>";
echo "<option value='$x'>'$x'</option>";
}

 

Correct me if I am wrong, but the echo will just echo the x variable. I am not sure why you while looped and fetched the same entry twice. Also, when inside of an echo use the single quotes.

Edited by computermax2328
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.