Hello,
I have an application that stores information about members regarding activities for which they wish to be listed. In some cases, they can be included in a sub category within that activity. E.G. Fishing Resorts and Resorts in USA as the sub category.
I have a query to mySQL that works fine if I enter the select statement into phpMyAdmin. It returns the expected 5 records. However, the same statement on the PHP page returns only 4 records. It fails to show the last record entered. If I enter another record, the one previously missing shows up, but not the newest one.
Here is the query:
if($activity){
$new_query = "SELECT tblMemberActivities.ActivityID, tblMemberActivities.CategoryID, tblmembers.MemberID, tblmembers.MemberName, tblmembers.SiteName, tblmembers.Status, tblActivityCategories.ActivityCategoryName, tblActivities.ActivityName FROM tblMemberActivities LEFT OUTER JOIN tblmembers ON tblMemberActivities.MemberID = tblmembers.MemberID LEFT OUTER JOIN tblActivityCategories ON tblMemberActivities.CategoryID = tblActivityCategories.ActivityCategoryID LEFT OUTER JOIN tblActivities ON tblMemberActivities.ActivityID = tblActivities.ActivityID WHERE tblMemberActivities.ActivityID = $activity ORDER BY tblmembers.MemberName";
$new_result = mysql_query($new_query);
$query_data = mysql_fetch_array($new_result);
$ActivityName = $query_data[ActivityName];
}{
The code for displaying the results of the query is as follows:
if($new_result){
while($row = mysql_fetch_array($new_result)){
$color=$counter++%2?'#ffffff':'#eaeaea';
echo("<tr bgcolor=\"$color\">\n"
."<td width=\"300\" valign=\"top\"><a href=\"goplay_member_activity_edit.php?id=$row[MemberID]&activity=$activity\" title=\"Edit this record\">$row[MemberName]</a>");
if ($row[ActivityCategoryName] != ""){echo(" - <span style=\"font-size:10px;\">$row[ActivityCategoryName]</span>");
}
echo("</td>\n"
."<td align=\"center\" width=\"100\">");
if ($row[Status] == 1){
echo("Active");
}
else{echo("<span style=\"color:red;\">Inactive</span>");}
echo("</td>\n");
echo("<td width=\"200\" align=\"center\"><input type=\"checkbox\" name=\"deleteBox[]\" id=\"deleteBox\" value=\"$row[MemberID]\"></td>\n"
."</tr>\n");
}
}
echo("<tr>\n"
."<td width=\"300\"><input type=\"submit\" name=\"btn_delete\" value=\"Remove all checked records\" onClick=\"return chkBoxLoop();\"></td>\n"
."</tr>\n"
I have looked at this query for way too long and tried various alterations to the join statements, added and deleted columns, to no avail. I may be missing something obvious, but I'm still missing it. Can anyone see what is wrong with this query? Please note, that it seems to work fine if the activity selected has no sub categories. All records are returned in that case. But I can't see why it would fail with sub categories and do so only in the number of records returned, not in general.
Thanks for any help.