Jump to content

Displaying from single field


Go to solution Solved by Pikachu2000,

Recommended Posts

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?

 

 

Link to post
Share on other sites
  • Solution

$sql = "SELECT id, category, bilde, title FROM oppskrift_table WHERE category = 'Appetizers & Beverages' ORDER BY title ";

Edited by Pikachu2000
Link to post
Share on other sites
This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.