adzie Posted February 23, 2012 Share Posted February 23, 2012 Hello all, Appreciate your advice as i've hit a wall now Table 1 - user_awards award_id award_title Table 2 - awards user_id (a column for each award_id) 0 = no, 1 = yes I'd like to ideally create a result where it then displays all the records where the column in table 2 is 1 but I want to limit it to say 5 where the user_awards table = 1, however at present it counts five including entries where its 0. This is where i'm getting unstuck so appreciate any advice. Code snippet below. $awardCodes = mysql_query("SELECT * FROM `user_awards` WHERE `user_id` = 1"); $awardsres = mysql_fetch_assoc($awardCodes); $awards = mysql_query("SELECT * FROM `awards` ORDER BY 'award_id' ASC LIMIT 4"); // Loop through award codes while ($ac2 = mysql_fetch_assoc($awards)) { $ac22 = db_entry_check($awardsres[$ac2[award_id]])? 1 : 0; if ($ac22 != $actual && $ac22 == 1) { echo "$ac22[award_title]"; } } Quote Link to comment https://forums.phpfreaks.com/topic/257620-link-two-tables-but-limit-results/ Share on other sites More sharing options...
fenway Posted February 25, 2012 Share Posted February 25, 2012 Sorry, I don't follow. Quote Link to comment https://forums.phpfreaks.com/topic/257620-link-two-tables-but-limit-results/#findComment-1321122 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.