Spring Posted November 25, 2011 Share Posted November 25, 2011 $sql = "SELECT poster_id from phpbb_posts WHERE topic_id = ".$topic_id." "; $result = $db->sql_query($sql); //same as mysql_query $row = $db->sql_fetchrow($result); // same as mysql_fetch array. var_dump($row); With this code (i commented the query function for you) im getting array 'poster_id' => string '59' (length=2) When I run this into SQL in phpmyadmin I'm getting 59 56 //this is what I want I need to get all of the records, not just the first one. I have even tried using replacing the function with mysql_query and mysql_fetch_array any ideas? It's a bit late, so I may just be making a simple mistake. Thanks! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2011 Share Posted November 25, 2011 Where's the while() loop you're using to fetch the records from the result resource? Quote Link to comment Share on other sites More sharing options...
Spring Posted November 25, 2011 Author Share Posted November 25, 2011 Where's the while() loop you're using to fetch the records from the result resource? Shouldn't both values be inside of $row though? When I use a var_dump I'm only getting one value? I tried using a foreach, and every result came out with 59. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2011 Share Posted November 25, 2011 No. You're selecting one field from each record. Each iteration of a loop over mysql_fetch_* will hold one record, with that record's selected field(s) in an array. Quote Link to comment Share on other sites More sharing options...
Spring Posted November 25, 2011 Author Share Posted November 25, 2011 No. You're selecting one field from each record. Each iteration of a loop over mysql_fetch_* will hold one record, with that record's selected field(s) in an array. So I should loop this? $result = $db->sql_query($sql); Quote Link to comment Share on other sites More sharing options...
Spring Posted November 25, 2011 Author Share Posted November 25, 2011 I got it, thanks! while($row = $db->sql_fetchrow($result)) { var_dump($row); }; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2011 Share Posted November 25, 2011 In procedural style code, it would be like this. $sql = "SELECT poster_id from phpbb_posts WHERE topic_id = ".$topic_id." "; $result = mysql_query($sql); while( $row = mysql_fetch_row($result) ) { var_dump($row); } Quote Link to comment 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.