Re: Categories and Items query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, I figured out how to do my nested loop, so now I think it's a fairly small problem that I have now: how to only select features that should show on the Deluxe Home Features page, or the Standard Home Features page.
I have a table named feature_sets with three values (plus keys): both, standard only or deluxe only. I designed it this way because for some features, such as the wood trim, there is an upgraded version (e.g. oak vs. pine), some features are common to both homes, and a couple are exclusive to the deluxe home.
I have my nested loop working so it lists the category then lists the features in that category in a bulleted list, but it's currently pulling out ALL of the features, not just the "all homes" and "deluxe" (which is the page I am working on. When I try to add an additional AND statement to limit the features to only those with 1 or 3 as their featureset_id, I end up with a list that has ALL the features showing up under each of the categories.


Is there a way that I can limit my query to just two of the three featureset IDs?

Any help would be much appreciated!

My code:

<?php require_once('[appropriate connection info here]');

		$query_categories = "SELECT * FROM feature_categories";
		$categories = mysql_query($query_categories) or die(mysql_error());
		$row_categories = mysql_fetch_assoc($categories);
		$totalRows_categories = mysql_num_rows($categories);
?>

<?php do { ?>
<table width=100% class="featuretable">
<tr>
<td><b><?php echo $row_categories['category'];
?>
</b></td>
</tr>
</table>
<?php
$query_features = "SELECT feature_description FROM features WHERE feature_category_id = ".$row_categories['feature_category_id']."";
$features = mysql_query($query_features) or die(mysql_error());
$row_features = mysql_fetch_assoc($features);
$totalRows_features = mysql_num_rows($features);

do { ?>

<table width="100%" border="0" cellpadding="2" class="featuretable">
<tr>
<td><ul>
<li><?php echo $row_features['feature_description']; ?></li></ul></td>
</tr>
</table>
<?php } WHILE ($row_features = mysql_fetch_assoc($features));
} WHILE ($row_categories = mysql_fetch_assoc($categories));
mysql_free_result($categories);
mysql_free_result($features);
mysql_close();
?>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux