PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
set curr_section = "";
loop through $row {
if curr_section != $rowїsection_name] {
output name of section
}
output name of subsection
set curr_section = $rowїsection_name];
}
<?php
function genSection()
{
$query = "SELECT * FROM section";
$result = dbquery($query);
while($menu_data = mysql_fetch_array($result))
{
echo "<p><b>$menu_data['section']</b></p>";
genSubSection($menu_data['id']);
}
}
function genSubSection($id)
{
$query = "SELECT * FROM subsection WHERE id = '$id'";
$result = dbquery($query);
while($subsection_data = mysql_fetch_array($result))
{
echo "<p>$subsection_data['subsection']</p>";
}
}
?>
Also, scroll down on this link and read the part titled "Array do's and don'ts - Why is $foo[bar] wrong?" Notice I added quotes into the arrays. This isn't a big error, but its worth noting for future reference.
This is what i came up with as my final product. Please comment on it. Thi is only the backbone and does not include any of my HTML if you are wondering.