I've got a PHP MySQL query to grab featured products from a MySQL database, the query then left joins another table for the product image.
However the way I have my website design laid out the while query needs to stop and then continue.
I have an arrow that points left and then an arrow that points right, either side of the image, to navigate through the featured products. However the image itself is called before the two buttons.
I either need to stop the loop and then continue it, or find another way? Otherwise the buttons get echoed for each product that is called.
This is what I mean:
echo '<div class="slides_container">';
echo '<div class="slideItem" style="display: none"><a href="product.php?id='.$q['id'].'"><img src="images/dummy/pic_1.jpg" alt="" /></a></div>';
echo '</div>';
echo '<a class="s_button_prev" href="javascript:;"></a>';
echo '<a class="s_button_next" href="javascript:;"></a>';
Here's all of it in one:
if (!$query = @mysql_query("
SELECT *
FROM products
LEFT JOIN products_img_lookup ON products_img_lookup.nil_products_id = products.id
WHERE featured = 1
GROUP BY products.id
ORDER BY id DESC")) {
echo '<strong>Error:</strong> '.mysql_error().'';
} else {
$c = 0;
while ($q = mysql_fetch_array($query)) {
$detail = stripslashes($q['description']);
$detail = strip_tags($detail);
echo '<h2><a href="product.php?id='.$q['id'].'">'.$q['name'].'</a></h2>';
echo '<p class="s_desc">'.trim_text($detail,25).'</p>';
echo '<div class="s_price_holder">';
echo '<p class="s_price"> <span class="s_currency s_before">£</span>'.$q['price'].' </p>';
echo '</div>';
echo '</div>';
echo '<div id="product_intro_preview">';
echo '<div class="slides_container">';
echo '<div class="slideItem" style="display: none"><a href="product.php?id='.$q['id'].'"><img src="images/dummy/pic_1.jpg" alt="" /></a></div>';
echo '</div>';
echo '<a class="s_button_prev" href="javascript:;"></a>';
echo '<a class="s_button_next" href="javascript:;"></a>';
echo '</div>';
}
}