madness69 Posted October 23, 2012 Share Posted October 23, 2012 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 https://forums.phpfreaks.com/topic/269805-query-problem-doesnt-bring-listings-other-column/ Share on other sites More sharing options...
Christian F. Posted October 23, 2012 Share Posted October 23, 2012 What's the problem, or rather question? PS: Make sure you've turned on error reporting, and that there are no errors in the error log. Link to comment https://forums.phpfreaks.com/topic/269805-query-problem-doesnt-bring-listings-other-column/#findComment-1387189 Share on other sites More sharing options...
computermax2328 Posted October 23, 2012 Share Posted October 23, 2012 On 10/23/2012 at 9:30 AM, madness69 said: $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. Link to comment https://forums.phpfreaks.com/topic/269805-query-problem-doesnt-bring-listings-other-column/#findComment-1387268 Share on other sites More sharing options...
Barand Posted October 23, 2012 Share Posted October 23, 2012 The second while loop will not output any data as you already reached the end of the resultset in the first loop. You would need a data_seek instruction to return to the beginning again. Link to comment https://forums.phpfreaks.com/topic/269805-query-problem-doesnt-bring-listings-other-column/#findComment-1387323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.