barryflood22 Posted October 22, 2012 Share Posted October 22, 2012 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 More sharing options...
Christian F. Posted October 22, 2012 Share Posted October 22, 2012 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 (). Link to comment https://forums.phpfreaks.com/topic/269778-help-needed-with-simple-query/#findComment-1387038 Share on other sites More sharing options...
Barand Posted October 22, 2012 Share Posted October 22, 2012 How many more times do you intend to post this same query with similar faulty code? See also http://forums.phpfreaks.com/topic/269783-select-where-echo/ Link to comment https://forums.phpfreaks.com/topic/269778-help-needed-with-simple-query/#findComment-1387075 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.