I've a mySQL db with two tables - advertisers and category. If the advertiser is active, I'd like to have the category name appear, with all active advertisers below, and then the following category, etc. Right now I'm testing and have everything active.
Quick structure on tables are
advertisers contains id, category_id, name, img1, img2, and active (tinyint with all set to 1 for now)
category contains id, category
My current code outputs the category with a space and then the name with a break.
Really need to be
Category name (this will be an h1)
Advertiser name (paragraph)
another Advertiser name
Next Category name (and so on)
Here's what I have to date.
<?php require_once("includes/connection.php"); ?>
<table>
<tr>
<td>
<?php
// Perform database query
$result = mysql_query("SELECT * FROM advertisers
INNER JOIN category
ON advertisers.category_id = category.id
WHERE advertisers.active = 1
ORDER BY name");
if (!$result) {
die("Database query failed: " . mysql_error());
}
// Use returned data
while ($row = mysql_fetch_array($result)) {
echo $row["category"]." ".$row["name"]."<br />";
}
?>
</td>
</tr>
</table>
<?php include("includes/footer.php"); ?>
Point me please. I'm thrilled to have gotten this far.:$
Donna