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