zang8027 Posted February 25, 2009 Share Posted February 25, 2009 Ok, got my first problem solved using a normal join. Now, i am getting the restaurant name. Now, i am not getting a city name and I cant figure out the scope to do this. I need to edit that query where it joins 3 tables if possible. So i can get the city name from city table joined on "cityID" to clientReceipts on "cityID" <?php $query="SELECT userID,restID,cityID,price,time,restaurant_name FROM clientReceipt JOIN restaurants ON clientReceipt.restID = restaurants.restaurant_ID WHERE userID=$userID ORDER BY time"; $result=mysql_query($query); //create a table print " <table id='menuDisplayTable'> <colgroup> <col id='restCol' /> <col id='cityCol' /> <col id='priceCol' /> <col id='timeCol' /> <col id='delete' /> </colgroup> <thead> <tr> <th scope='col'>Restaurant</th> <th scope='col'>City</th> <th scope='col'>Price</th> <th scope='col'>Date</th> <th scope='col'>Delete</th> </tr> </thead> <tbody> "; //we need to color every odd row so that its easier to read. Create a row variable $rows = 1; print "<tr>"; while($row = mysql_fetch_array($result)) { $rest = $row['restID']; $city = $row['cityID']; $price = $row['price']; $timedate = $row['time']; $restName = $row['restaurant_name']; //rows print "<td>$restName</td><td>$city</td><td>$$price</td><td>$timedate</td><td> Quote Link to comment https://forums.phpfreaks.com/topic/146928-err-problem-two-with-keys/ Share on other sites More sharing options...
zang8027 Posted February 25, 2009 Author Share Posted February 25, 2009 so what im saying is it possible to join 3 tables in a single statement? Quote Link to comment https://forums.phpfreaks.com/topic/146928-err-problem-two-with-keys/#findComment-771361 Share on other sites More sharing options...
Maq Posted February 25, 2009 Share Posted February 25, 2009 so what im saying is it possible to join 3 tables in a single statement? Yes. Quote Link to comment https://forums.phpfreaks.com/topic/146928-err-problem-two-with-keys/#findComment-771369 Share on other sites More sharing options...
sasa Posted February 25, 2009 Share Posted February 25, 2009 basic syntax SELECT blah.... FROM table1 JOIN table2 ON ... JOIN table3 ON ... WHERE ... Quote Link to comment https://forums.phpfreaks.com/topic/146928-err-problem-two-with-keys/#findComment-771374 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.