Jump to content

Recommended Posts

i have two tables cross referencing each other but for some reason it wont populate the "country" results, below is my code, can anyone help?

 

 <?php
//ECHO LOCATION 
echo '<p><b>Location: </b>';
   // get area details
   $query2="select * from jos_RAM_areas WHERE id = '".$row['area']."' ";
   $sth2=mysql_query($query);
   $num_rows2 = count($sth2);
   // record found?
   if ($num_rows2>0) {
 $row2=$sth2[0]; // get the record details (now in an array)
 $Country=$row2['Country'];
 $County=$row2['County'];
 if ($County!='') { $Area = "$Country, $County"; } else { $Area = "$Country"; }
   } else {

   } // eof check for record found
   echo $Area;
   $town_city = $row['town_city'];
   if ($town_city!='') { echo "$country\n\n$town_city"; }




 ?>

Link to comment
https://forums.phpfreaks.com/topic/269778-help-needed-with-simple-query/
Share on other sites

Run a var_dump () on $sth2 right after the test on $num_rows > 2, and you should see the reason for yourself.

I'll give you a hint: You've forgotten something that's shown in the example in the PHP manual, for mysql_query ().

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.