Jump to content

Mysql fetch array not working correctly


dailyprofit

Recommended Posts

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");

Link to comment
https://forums.phpfreaks.com/topic/149872-mysql-fetch-array-not-working-correctly/
Share on other sites

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'] . ";
}

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 :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.