justapilot Posted October 8, 2010 Share Posted October 8, 2010 I have a variable called clientid being passed via a url. I place that in a variable called $clientid I have two tables, client and web_info I want to select all from client and web_info for the appropriate clientid. I may not have my tables set up correctly. The primary key on the table client is auto genereated and titled client_id the primary key on web_info is e_mail and I want to pull information from the table web_info where the e_mail columns match. Below is my PHP: $query = "SELECT * FROM client WHERE $clientid = client_id and FROM web_info WHERE client.e_mail = web_info.e_mail"; $result = mysqli_query($connection,$query); $row = mysqli_fetch_array($result); I know I probably screwed all this up but please help Quote Link to comment https://forums.phpfreaks.com/topic/215465-two-tables-and-results/ Share on other sites More sharing options...
jcbones Posted October 8, 2010 Share Posted October 8, 2010 Try this: same but re-ordered. $query = "SELECT client.*, web_info.* FROM client , web_info WHERE client.e_mail = web_info.e_mail AND $clientid = client_id"; Quote Link to comment https://forums.phpfreaks.com/topic/215465-two-tables-and-results/#findComment-1120414 Share on other sites More sharing options...
justapilot Posted October 8, 2010 Author Share Posted October 8, 2010 Perfect! That got rid of my select error, how do I echo out the result? When it was just one table I was using echo $row['column_name']; Quote Link to comment https://forums.phpfreaks.com/topic/215465-two-tables-and-results/#findComment-1120422 Share on other sites More sharing options...
jcbones Posted October 8, 2010 Share Posted October 8, 2010 You can still do that, but if the column names in the two tables collide(same name) you may get an ambiguous message. You would then need to use alias's. I would try it without them first. Quote Link to comment https://forums.phpfreaks.com/topic/215465-two-tables-and-results/#findComment-1120424 Share on other sites More sharing options...
justapilot Posted October 8, 2010 Author Share Posted October 8, 2010 Its not displaying any results when I try that echo statement. Quote Link to comment https://forums.phpfreaks.com/topic/215465-two-tables-and-results/#findComment-1120426 Share on other sites More sharing options...
justapilot Posted October 9, 2010 Author Share Posted October 9, 2010 Nevermind.. I didnt have any data in the second table.. all is good to go.. THANK YOU!!!! Quote Link to comment https://forums.phpfreaks.com/topic/215465-two-tables-and-results/#findComment-1120430 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.