Jump to content

Matching data between tables


Jacko623

Recommended Posts

Hi everyone,

 

I hired some guys to create a site for me, and they did a shoddy job.  Right now, I have one table that displays a bar name, details, a city.  The city in the first table is a number, which responds to an integer in a second table which corresponds to a specific text.  For example

Bar_Details:

Bar:  The Rock Bottom

Town: 1

Description: Blah blah blah

City_Details:

ID: 1

Town: New York City

 

Here is the script (which returns NO errors):

 

$ConDB=mysql_connect($hostname,$username,$password);
$DB=mysql_select_db($dbname,$ConDB);

[color=blue]//Query Information	[/color]

$query = "SELECT bar_name,bar_descrip,city FROM partynj_bar_details ORDER by Rand() limit 0,1"; 
$result = mysql_query($query);
[color=blue]//print information	[/color]
while(list($bar_name,$bar_descrip) =  mysql_fetch_array($result))
{ ?>
    <a href="../bars/?<?=stripslashes($bar_name)."|".$id?>&act=all"><?=stripslashes($bar_name)?></a><br>
<?	
echo stripslashes("Name : $bar_name <br>");
echo stripslashes("Description : $bar_descrip <br><br>");
} 
[color=blue]//Troublesome area[/color]
$query2 = "SELECT city FROM partynj_citylist WHERE id='$city'";	
$result2 = mysql_query($query2);
[color=blue]//print information[/color]
echo stripslashes($bar_name)?> is located in <?=stripslashes($results2); 

?>

Now, everything works fine, up to the //troublesome remark.

When I generate the page the first part generates a random bar, a link, the title and the description.  The second part should display the what town the bar is located in, but instead only returns "is located in". There are no errors.

 

What do you think?

 

 

Link to comment
https://forums.phpfreaks.com/topic/38990-matching-data-between-tables/
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.