I'm fetching a list of "favorites" from a MySQL database using PHP. Unfortunately, only the first result of the database is returned... I'd appreciate if anyone would have a look:
I have the following code:
if($userid != 0){
$favq = mysql_query(
"SELECT storyid
FROM storyfavorites
WHERE userid ='$userid'",$conn)
or die(mysql_error());
$fav = mysql_fetch_row($favq);
}
Querying the following table in the database:
Quote
| userid | storyid |
| 29 | 144 |
| 29 | 143 |
| 29 | 130 |
| 29 | 142 |
| 29 | 140 |
| 29 | 141 |
| 29 | 36 |
| 29 | 144 |
| 29 | 143 |
| 29 | 130 |
| 29 | 142 |
| 29 | 140 |
| 29 | 141 |
| 29 | 36 |
When I query the database using the PHP code above, I get this in return (vardump):
Quote
array(1) { [0]=> string(3) "144" }
As you can see, that's only the first row of the table. HOWEVER, when I query the database directly WITHOUT the PHP code, I get all the correct values returned.
It's late and I'm probably missing something very simple, but I'd appreciate if anyone would help me fix it.
Thanks
- Cbeppe
P.S the PHP variable '$userid' correctly equals 29. Checked using var_dump();
This post has been edited by Cbeppe: 12 March 2012 - 04:06 PM

New Topic/Question
Reply




MultiQuote




|