K_N Posted April 13, 2011 Share Posted April 13, 2011 I have a very small table right now, looks just like this: I'm using the following code $watchQuery = "SELECT `watched` FROM `watch` WHERE `watcher` = '1'"; $watching = mysql_fetch_array(mysql_query($watchQuery)); And the array $watching comes out like this: [0] => 0 [watched] => 0 What obvious mistake am I looking over that is causing this query to not select every row with a 'watcher' value of 1 (i.e. All of them)? Quote Link to comment https://forums.phpfreaks.com/topic/233569-select-query-only-returns-one-row/ Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 It's certainly selecting all the rows that match, but if you don't loop through the results, you'll only see one result. while( $array = mysql_fetch_assoc($watchQuery) ) { echo "Watched: {$array['watched']}<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/233569-select-query-only-returns-one-row/#findComment-1200978 Share on other sites More sharing options...
K_N Posted April 13, 2011 Author Share Posted April 13, 2011 It's certainly selecting all the rows that match, but if you don't loop through the results, you'll only see one result. while( $array = mysql_fetch_assoc($watchQuery) ) { echo "Watched: {$array['watched']}<br>"; } D'oh. I'm doing the same thing 3 other times in this script. Can't believe I missed that. Well, on my other issue, can you inform me on how to strip the index out of the array, so it only shows up as [watched] => 0 [watched] => 1 [watched] => 2 etc? Or should I take that to the PHP forum? Quote Link to comment https://forums.phpfreaks.com/topic/233569-select-query-only-returns-one-row/#findComment-1200979 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.