Jump to content

err problem two with keys


zang8027

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/146928-err-problem-two-with-keys/
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.