seany123 Posted April 1, 2009 Share Posted April 1, 2009 i have two tables which i need to pull values from ones called "players" and it has a all information about the user and (city_id) in it. The other table is called "city" and it has (city_id and city_name) in it what i want to do is when $players->city_id = 1.... for it to echo the name of the city using the (city) table. the last catch is im trying to do a page which shows alot of different peoples "city_name" value... heres the code i already have... <?php /Check for user ID if (!$_GET['id']) { header("Location: members.php"); } else { $query = $db->execute("select `id`, `username`, `city_id` from `players` where `username`=?", array($_GET['id'])); if ($query->recordcount() == 0) { header("Location: members.php"); } else { $profile = $query->fetchrow(); } } ?> now if i set the below code to $player->city_id... then it displays MY city name... but setting it to profile doesnt show anyones. <? $query = $db->execute("select * from `city` where `city_id` like '$profile->city_id'"); $city = $query->fetchrow(); ?> to echo my code: <?=($city['city_name'])?> can anyone give me a hand? Link to comment https://forums.phpfreaks.com/topic/152005-help-using-two-tables-from-database/ Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 Does the query itself return the correct resultset? Link to comment https://forums.phpfreaks.com/topic/152005-help-using-two-tables-from-database/#findComment-799323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.