HDFilmMaker2112 Posted May 14, 2011 Share Posted May 14, 2011 The following code is returning only one row, when I know for a fact there are two entries with same product_category in the database. Maybe I'm just missing something blatantly obvious, but I'm not seeing an error in the code. if(isset($_GET['cat'])){ $cat=$_GET['cat']; $sql30="SELECT * FROM $tbl_name WHERE product_category='$cat'"; $result30=mysql_query($sql30); while($row30=mysql_fetch_array($result30)){ $content=$row30['product_category']; } } Link to comment https://forums.phpfreaks.com/topic/236387-simple-select-from-only-returning-one-row/ Share on other sites More sharing options...
HDFilmMaker2112 Posted May 14, 2011 Author Share Posted May 14, 2011 Here's my table: product_id | product_name | product_category | product_tag | product_link | product_price 2 | test | test | test | test | 1 3 | test2 | test2 | test2 | test2 | 2 4 | test2 | test | test | test | 12 EDIT: Just realized my issue, I needed to concatenate the $content variable because it's looping... it was just taking the last entry because it kept overwriting the $content variable from the last loop. code is now: if(isset($_GET['cat'])){ $cat=$_GET['cat']; $sql30="SELECT * FROM $tbl_name WHERE product_category='$cat'"; $result30=mysql_query($sql30); while($row30=mysql_fetch_array($result30)){ $content.=$row30['product_category']; } } Link to comment https://forums.phpfreaks.com/topic/236387-simple-select-from-only-returning-one-row/#findComment-1215299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.