grlayouts Posted July 20, 2008 Share Posted July 20, 2008 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 More sharing options...
teynon Posted July 20, 2008 Share Posted July 20, 2008 No one knows because you haven't posted anything but your select query. You need to post your insert queries and the rest of your script. Link to comment https://forums.phpfreaks.com/topic/115701-wrong-user/#findComment-594850 Share on other sites More sharing options...
grlayouts Posted July 20, 2008 Author Share Posted July 20, 2008 why? it inserts ok! it displays the correct record for the number just not the right user under $row[0] so why would you need the insert? Link to comment https://forums.phpfreaks.com/topic/115701-wrong-user/#findComment-594855 Share on other sites More sharing options...
teynon Posted July 20, 2008 Share Posted July 20, 2008 I don't know. I must not know what I'm talking about.... Looks like your stuck on your own then.... Link to comment https://forums.phpfreaks.com/topic/115701-wrong-user/#findComment-594856 Share on other sites More sharing options...
cooldude832 Posted July 20, 2008 Share Posted July 20, 2008 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 More sharing options...
grlayouts Posted July 20, 2008 Author Share Posted July 20, 2008 fair enough. but it picks up the row[2] fine? can you suggest how i would get the person in the (attackdetails) to show if they had the most of type 4? Link to comment https://forums.phpfreaks.com/topic/115701-wrong-user/#findComment-594864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.