JNew Posted August 19, 2016 Share Posted August 19, 2016 I created a recipe site that displays various dishes, and I'm tickled pink that I got it to work (first time doing this!) But I'd like to have pages that displays dishes by its category. The column that houses this is called "category" which has 7 total: Appetizers & Beverages, Soups & Salads, Side Items, Main Dishes, Baked Goods, Desserts, and Cookies & Candy. I have this page connected to a "connection.php" page, but here's the code in question: <!-- Page Title--> <div class="row"> <div class="col-lg-12"> <h1 class="page-header">Appetizers & Beverages</h1> </div> </div> <!-- /Page Title --> <!-- Displayed Data--> <?php $sql = "SELECT id, category, bilde, title FROM oppskrift_table ORDER BY title "; $result = mysqli_query($con, $sql); if(mysqli_num_rows($result) > 0 ){ while($row = mysqli_fetch_assoc($result)){ ?> <div align="center" class="col-md-3"> <a href="#"> <img class="img-responsive img-cat" src="bilder/rBilder/<?=$row['bilde']?>" width="250" alt=""> </a> <h4 style="max-width:250px;"> <a href="#" class="dishes"> <?=$row['title']?> </a> </h4> </div> <?php } } ?> <!-- END Displayed Data--> </div> How can I tweak this so that only the category Appetizers & Beverages shows up on the page? Quote Link to comment https://forums.phpfreaks.com/topic/301945-displaying-from-single-field/ Share on other sites More sharing options...
Solution Pikachu2000 Posted August 19, 2016 Solution Share Posted August 19, 2016 (edited) $sql = "SELECT id, category, bilde, title FROM oppskrift_table WHERE category = 'Appetizers & Beverages' ORDER BY title "; Edited August 19, 2016 by Pikachu2000 Quote Link to comment https://forums.phpfreaks.com/topic/301945-displaying-from-single-field/#findComment-1536345 Share on other sites More sharing options...
JNew Posted August 19, 2016 Author Share Posted August 19, 2016 (edited) High five. Thanks! Edited August 19, 2016 by JNew Quote Link to comment https://forums.phpfreaks.com/topic/301945-displaying-from-single-field/#findComment-1536347 Share on other sites More sharing options...
benanamen Posted August 19, 2016 Share Posted August 19, 2016 It would appear your database is set up incorrectly. Category should be the category ID tied to a separate category table. Quote Link to comment https://forums.phpfreaks.com/topic/301945-displaying-from-single-field/#findComment-1536348 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.