soltek Posted December 31, 2011 Share Posted December 31, 2011 Hello again, guys! I'm trying to do this: Get $user_ID -> SELECT FROM favorites WHERE user="$user_ID" -> Now I should create an array with the ID of all the results of the previous command -> SELECT FROM books WHERE genre="$favorites_ID" -> populate a html table. The part I've no idea about how to do is building an array with the results and then using the SELECT command, find in the other tables the match. Could you please give me a hand - one more time? Quote Link to comment https://forums.phpfreaks.com/topic/254134-build-an-array-with-sql/ Share on other sites More sharing options...
The Little Guy Posted December 31, 2011 Share Posted December 31, 2011 I think a query like this will give you what your looking for: echo "<table>"; $sql = mysql_query("select * from favorites f left join books b on(f.favorites_id = b.genre) where f.user = $user_ID"); while($row = mysql_fetch_assoc($sql)){ echo <<<ROWS <tr> <td>{$row["book_title"]}</td> <td>{$row["book_genre"]}</td> </tr> ROWS; } echo "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/254134-build-an-array-with-sql/#findComment-1302878 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.