Jump to content

wrong user


grlayouts

Recommended Posts

i have a code which takes the records from the database and displays the highest record. now its for a product called supply stations. however when someone new sets the record the record changes but the user remains the same.. any idea's what wrong with my code?

 

   $sql = "SELECT users.handle,max(attackdetails.amount) FROM users,attackdetails WHERE users.id=attackdetails.who AND attackdetails.type=4 GROUP BY type";
   $r = mysql_query($sql); $row = mysql_fetch_row($r);
   print"$row[0]";
   tableEntry(array('Most Supply Stations Won in an Attack', $row[0], number_format($row[1])), 'align="center"');

Link to comment
https://forums.phpfreaks.com/topic/115701-wrong-user/
Share on other sites

in your query (your select) The user table data is completely dependent on the attackdetails table  (users.id=attackdetails.who) 

 

I don't see you defining a (where Users.id = '".$this->userid."') as I expected.

 

That where clause should be replaced with a LEFT JOIN but really the query is a fairly arbitrary query that nets no good data other than a list of joining those two tables on (users.id=attackdetails.who)

Link to comment
https://forums.phpfreaks.com/topic/115701-wrong-user/#findComment-594859
Share on other sites

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.