I have set up a page that displays the products_options_values_id as a list (candle scents).
I have linked them to the products_description by joining the products_attributes using the products_id.
Everything seems to be working fine and I get a list of the products for the option_values.
However, the list is missing the first result? i.e.- product_id #31,#32,#33,#34,#35, #36,#37,#38 are displayed but for some reason product_id #30 is not listed.
This same problem re-occurs for any option_value selected and always seems to be the first result not being displayed.
Here is a link to show you what I'm dealing with.
http://huguenotcandleco.com/scent_info.php?products_options_values_id=49
Obviously Alaskan Wilderness is the scent (products_options_value_id)#49
and the candle types are the (products_id)
Here is my code to get to this point?
<?php
require_once('connectvars.php');
require_once('appvars.php');
$products_options_values_id = $_GET['products_options_values_id'];
// Grab the profile data from the database
$query = "SELECT * FROM products_attributes, products_options_values " . "WHERE products_attributes.options_values_id='$products_options_values_id' AND products_options_values.products_options_values_id='$products_options_values_id'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
if ($row != NULL) {
$products_id = $row['products_id'];
}
// Loop through the array of user data, formatting it as HTML
echo '<h4>These are the candles currently available in ';
echo $row['products_options_values_name'];
echo '</h4> <br>';
echo ' <img src="' . MM_UPLOADPATH . $row['image_path'] . '" border="0" alt="' . $row['products_options_values_name'] . '" /> <br>';
while ($row = mysqli_fetch_array($data))
{
// Grab the products from the attributes and description tables
$query2 = "SELECT * FROM products_description INNER JOIN products_attributes USING (products_id) WHERE products_id='" . $row['products_id'] . "'";
$data2 = mysqli_query($dbc, $query2);
$row2 = mysqli_fetch_array($data2);
if ($row2 != NULL) {
$products_name = $row2['products_name'];
}
echo $row['products_id']; echo ' <a href="catalog/product_info.php?products_id=' . $row['products_id'] . '" border="0">' . $row2['products_name'] . '</a><br>';
}
?>
Any ideas or better code suggestions?
Latest News: (loading..)
List Products by Option Values
Started by Cinnaminh, Jan 16 2012, 15:33
No replies to this topic














