php and mysql logic problem, please help
Posted: Wed Nov 06, 2002 9:04 pm
hello everybody,
what am i trying to do: basically what i'm doing is pulling information from 2 databases and display them in 3 columns. this works but for somereason its not displaying the last couple of records.. this is what i have sofar http://www.comgen.ca/phptest/classified.php
there are 16 records in total but its only displaying 15
please help
what am i trying to do: basically what i'm doing is pulling information from 2 databases and display them in 3 columns. this works but for somereason its not displaying the last couple of records.. this is what i have sofar http://www.comgen.ca/phptest/classified.php
there are 16 records in total but its only displaying 15
please help
Code: Select all
$query1 = "SELECT categorydb.dbcategory AS CATEGORY, " .
"COUNT(classifieddb.dbcategory) AS ENTRIES " .
"FROM categorydb LEFT JOIN classifieddb " .
"ON categorydb.dbcategory =classifieddb.dbcategory " .
"GROUP BY CATEGORY";
$results = mysql_query($query1) or die("Query unsuccessful");
$num_of_category = mysql_num_rows($results);
echo $num_of_category;
while ($row = mysql_fetch_array($results))
{ if($category_c1 =="" || $category_c2 == "" || $category_c3 == "")
{ if($category_c1 == "")
{ $category_c1 = $rowї"CATEGORY"];
$entries_c1 = $rowї"ENTRIES"];
}
elseif($category_c2 == "")
{ $category_c2 = $rowї"CATEGORY"];
$entries_c2 = $rowї"ENTRIES"];
}
else
{ $category_c3 = $rowї"CATEGORY"];
$entries_c3 = $rowї"ENTRIES"];
echo "<span class='class1'>";
echo "<TR>";
//first col in a table format
echo "<TD align='right' width='3%'> <img src='bullet.gif'></TD>";
echo "<TD ALIGN ='LEFT' WIDTH='%20'> <font size=3><strong>";
echo $category_c1."(".$entries_c1.")</strong> </font></td>";
// sec. col. in a table format
echo "<TD align='right' width='3%'><img src='bullet.gif'></TD>";
echo "<TD ALIGN ='LEFT' WIDTH='%20'><font size=3><strong>";
echo $category_c2."(".$entries_c2.")</strong> </font></td>";
//third col. in table format
echo "<TD align='right' width='3%'><img src='bullet.gif'></TD>";
echo"<TD ALIGN ='LEFT' WIDTH='%20'><font size=3><strong>";
echo $category_c3."(".$entries_c3.")</strong> </font></td>";
echo "</TR>";
$category_c1 = ""; $entries_c1 = "";
$category_c2 = ""; $entries_c2 = "";
$category_c3 = ""; $entries_c3 = "";
}
}//if statment checking to see if the var. are empty or for input
}