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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.