PHP if statement help
Posted: Wed Mar 02, 2005 10:22 pm
I am reading a "main category" table and "subcategory" table then trying to write out the main category in H2 tags, then write the subcategories below it. For some reason, the if statement does not recognize when the main category is changing ( if (!$record["Main"] == $previous_main) ). Does anyone now why or know of an effective way of doing this?
Thanks... Ernest
Thanks... Ernest
Code: Select all
$result = mysql_query("SELECT mcat .mcat_name AS Main, scat .scat_name AS Sub
FROM mcat INNER JOIN scat ON mcat.mcatID = scat .maincat");
$previous_main = "";
while ($record = mysql_fetch_assoc($result)) {
if (!$recordї"Main"] == $previous_main) {
echo "<h2>".$recordї"Main"]."</h2>";
}
echo <font color='red'>".$recordї"Sub"]."</font> <br><br>";
$previous_main = $recordї"Main"];
}