I am new to php and I want to display the results from mySQl in an HTML table.
just to let you know, it is now 3 days I am working on it and I am about 45 to 50 cups of coffee and close to &^%*&$%^##$@#$...
for the moment this is what I get from my codes
Code: Select all
+-----+
| th |
+-----+-----+
|td | th |
+-----+-----+
|td | th |
+-----+-----+
|td |
+-----+
Code: Select all
+-----+-----+-----+
| th | th | th |
+-----+-----+-----+
| td | td | td |
+-----+-----+-----+
Code: Select all
<?php
// Connect to the database
include("_connect.php");
$catID = 2;
$sqlSub = "SELECT * FROM subCategories WHERE catID=$catID";
$querySub = mysql_query($sqlSub,$connect) or die ("subcategories");
echo "<table border=\"1\" cellpadding=\"10\">";
echo " <tr>";
while ($r1 = mysql_fetch_array($querySub)) {
$subCatName = $r1['subCatName'];
$subCatID = $r1['subCatID'];
$sqlPages = "SELECT * FROM pages WHERE catID='$catID' AND subCatID='$subCatID'";
$queryPages = mysql_query($sqlPages,$connect) or die ("pages");
echo " <th>".$subCatName. "</th>";
echo " </tr><tr>";
echo " <td>";
while ($r2 = mysql_fetch_array($queryPages)){
echo " <li><a href=\"pages.php?pageID=".$r2['pageID']."\">" .$r2['pageTitle']. "</a></li>";
}
echo " </td>";
}
echo " </tr>";
echo "</table>";
?>
thank you