des1017 Posted July 26, 2008 Share Posted July 26, 2008 $query = "SELECT * FROM $tablecategories"; $result = mysql_query($query); while($rowx = mysql_fetch_array($result, MYSQL_BOTH)) { echo " <div id='textheading'>" . $rowx['categoryname'] . "</div> <div id='naddition'> "; $queryz = "SELECT * FROM $tableunits WHERE unitcategory = " . $rowx['categoryname'] . "; $resultz = mysql_query($queryz); while($rowz = mysql_fetch_array($resultz, MYSQL_BOTH)) { echo " <div id='nitem'> <a href='jewelry.php?item=".$rowz["unitid"]."'><img src='jewelry/".$rowz["unitimage"]."' alt='".$rowz["unitname"]."' width='100' height='100'><br />-> Click Here</a> </div> "; } echo " </div> "; } Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource I'm having an issue with two while loops. I'm thinking either the query/result inside the first loop is an issue, or the select db where unitcategory = $categoryname Link to comment https://forums.phpfreaks.com/topic/116667-solved-php-mysql-select-db-where-issue/ Share on other sites More sharing options...
awpti Posted July 26, 2008 Share Posted July 26, 2008 drop an or die() after your query. It's likely returning an error. Link to comment https://forums.phpfreaks.com/topic/116667-solved-php-mysql-select-db-where-issue/#findComment-599848 Share on other sites More sharing options...
des1017 Posted July 26, 2008 Author Share Posted July 26, 2008 yea its dying.. the first loop works fine, definitely the second loop. Link to comment https://forums.phpfreaks.com/topic/116667-solved-php-mysql-select-db-where-issue/#findComment-599856 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 Do: $queryz = "SELECT * FROM $tableunits WHERE unitcategory = '{$rowx['categoryname']}'"; $resultz = mysql_query($queryz) or die(mysql_error()); What I just did: Added quotation marks around the string in the where clause Used proper array parsing technique in strings. It's much cleaner. Added a mysql_error() clause Please try that code. Link to comment https://forums.phpfreaks.com/topic/116667-solved-php-mysql-select-db-where-issue/#findComment-599872 Share on other sites More sharing options...
des1017 Posted July 26, 2008 Author Share Posted July 26, 2008 I just fixed it too. Thanks I really appreciate it, didn't know that was the proper way. Link to comment https://forums.phpfreaks.com/topic/116667-solved-php-mysql-select-db-where-issue/#findComment-599874 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 No problem, just mark this topic as Solved. Link to comment https://forums.phpfreaks.com/topic/116667-solved-php-mysql-select-db-where-issue/#findComment-599882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.