Jump to content

Query only returns one row of data - how to fix?


JTapp

Recommended Posts

Does anybody know what I need to add to the following query to get it to return more than one row of data?

 

<?php
$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingStateCode, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error());
if (mysql_num_rows($query)) {
while ($row = mysql_fetch_array($query)){
$variable20=$row["strOfficerTitle"];
$variable21=$row["strFirstName"];
$variable22=$row["strLastName"];
$variable23=$row["PersEmail"];
$variable24=$row["BusinessPhone"];

//table layout for results

print ("<tr>");
echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
echo "<td class=\"td_id\">$variable20</td>\n";
echo "<td class=\"td_id\">$variable21</td>\n";
echo "<td class=\"td_id\">$variable22</td>\n";
echo "<td class=\"td_id\">$variable23</td>\n";
echo "<td class=\"td_id\">$variable24</td>\n";
print ("</tr>");
}
}
?>

Hey guys - I'm going crazy.

 

The query is supposed to match a unique ID field ("lngLodgeID") from a table called tblLodges and to the same field in a table called tblOfficers and return some rows. 

 

When I first posted, I had a WHERE clause and only got one result when there were a couple more to report.

I took out the WHERE clause and now my problem is unique rows are not being returned - but I'm getting several rows.  ??? ??? ???

 

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID LIMIT 0, 50")or die(mysql_error());

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.