That worked a treat. Thanks!
Another question...Can I use the above method to also include categories? i.e. have the drinks and prices displayed within their categories, all on one page. I feel i'm not explaining this very well, what I want to achieve is:
Category name 1
-----------------
Drink 1 - Price 1
Drink 2 - Price 2
Category name 2
----------------
Drink 1 - Price 1
Drink 2 - Price 2
PHP Code:
$result = mysqli_query($link, 'SELECT drinks.id, drinks.name AS drinksname, promo, visible, price,
category.name AS categoryname FROM drinks
INNER JOIN price ON priceid = price.id
INNER JOIN drinkscategory ON drinksid = drinks.id
INNER JOIN category ON categoryid = category.id');
PHP Code:
while ($row = mysqli_fetch_array($result))
{
$drinks[] = array('id' => $row['id'], 'drink.name' => $row['drinksname'], 'promo' => $row['promo'],
'visible' => $row['visible'], 'price' => $row['price'], 'category' => $row['categoryname']);
}
include 'drinks.html.php';
drinks.html.php
PHP Code:
<?php foreach ($drinks as $drink): ?>
<h1><?php htmlout($drink['category']); ?></h1>
<div>
<ul>
<li><?php htmlout($drink['drink.name']); ?></li>
<li><?php htmlout($drink['price']); ?></li>
<?php if ($drink['promo'] == 'yes') {
echo '<li><input type="checkbox" checked="checked" /></li>';
} else {
echo '<li><input type="checkbox" /></li>';
}
?>
<?php if ($drink['visible'] == 'yes') {
echo '<li><input type="checkbox" checked="checked" /></li>';
} else {
echo '<li><input type="checkbox" /></li>';
}
?>
<li><input type="submit" value="Edit" /></li>
</ul>
</div>
<?php endforeach; ?>
Do I have to use two seperate SQL queries for this or is it achievable in this way? Thanks again.
Bookmarks