dailyprofit Posted March 17, 2009 Share Posted March 17, 2009 Hi, I have a php script where when you click an ad from table (ads), it records the (userid) of the clicker and the (adid) of the ad into a table called (clicks). So far I've manage to complete that part but I'm now trying to figure out how to get the code to show only ads from table (ads) where userid is NOT LIKE ($_SESSION[userid]) and not to show ads that was already shown to the user based off info in the table (clicks). So far I've also gotten as far as not showing the user/clicker it's own ads by using not like for the session userid... $result = mysql_query("SELECT * FROM ads WHERE `userid` NOT LIKE CONVERT(_utf8 '$_SESSION[userid]' USING latin1) COLLATE latin1_swedish_ci ORDER BY RAND() LIMIT 0 , 14"); Quote Link to comment https://forums.phpfreaks.com/topic/149872-mysql-fetch-array-not-working-correctly/ Share on other sites More sharing options...
dailyprofit Posted March 18, 2009 Author Share Posted March 18, 2009 Hi, for some reason I am unable to pull data from multiple tables when using the (mysql_fetch_array). Anytime I try to do (SELECT * FROM members, customers WHERE `userid` NOT LIKE '$member'), it brings back no results other words blank error because I've place (customers) after members in the FROM section. But if I take out the (`userid` NOT LIKE '$member'), then I can pull from multiple tables. So what should I do get pass this to get my code to work while allowing me to pull data from multiple tables for ($results) or is that (mysql_fetch_array) doesn't allow you to pull from multiple tables? This is what im trying to do but not working: -> $result = mysql_query("SELECT * FROM members, customers WHERE `userid` NOT LIKE '$member'"); while($row = mysql_fetch_array($result)) { echo "This is member number:" . $row['memid'] . "!<br>Member name is: " . $row['name'] . "; } Quote Link to comment https://forums.phpfreaks.com/topic/149872-mysql-fetch-array-not-working-correctly/#findComment-787777 Share on other sites More sharing options...
revraz Posted March 18, 2009 Share Posted March 18, 2009 Did you try putting the table names in front of the field name? Does userid exist in both tables? If so, I'm surprised you are not getting an ambiguous error. Quote Link to comment https://forums.phpfreaks.com/topic/149872-mysql-fetch-array-not-working-correctly/#findComment-787990 Share on other sites More sharing options...
dailyprofit Posted March 19, 2009 Author Share Posted March 19, 2009 Sorry for late response just got home from work. No I haven't tried putting the table name in front of the field name. You're saying like (field.table) e.g. (memid.members)? Yes the actual NOT LIKE is $_SESSION[userid], I just replaced with $member due to some copy and pasting techniques Quote Link to comment https://forums.phpfreaks.com/topic/149872-mysql-fetch-array-not-working-correctly/#findComment-788233 Share on other sites More sharing options...
fenway Posted March 19, 2009 Share Posted March 19, 2009 Don't double-post next time. Quote Link to comment https://forums.phpfreaks.com/topic/149872-mysql-fetch-array-not-working-correctly/#findComment-788278 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.