lolclol Posted May 3, 2013 Share Posted May 3, 2013 http://cffoodtoday.com/1.php hi I am fetching data from my database.. but I want to so the ingredients and methods are in order like <br /> is there a way to do this? <?php define("_VALID_PHP", true); require_once("init.php"); ?> <?php include("header.php");?> <!-- ============= CONTENT AREA STARTS HERE ============== --> <div id="left-area" class="clearfix"> <?php $conn = mysql_connect("localhost", "user", "password!"); mysql_select_db("_recipes", $conn) or die ('Database not found ' . mysql_error() ); $cust = $_GET["id"]; $sql = "select * from mr_recipes WHERE id='5' "; $rs = mysql_query($sql, $conn) or die ('Database not found ' . mysql_error() ); ?> <?php if (mysql_num_rows($rs)>0){ ?> <?php while ($row = mysql_fetch_array($rs)) { ?> <h1><?php echo $row["name"]?></h1> <span class="w-pet-border"></span> <div class="recipe-info"> <h2><a href="#"></a></h2> <div class="recipe-tags"> <span class="type">Date: <?php echo $row["addDate"]?></span> <span class="cuisine">Recipe By: </span> <?php echo $row["submitted_by"]?></div> <p>.<br /> </p></div> <div class="post recipe-listing-item"> <div class="list-left"> <h3 class="blue">Ingredients </h3> <!-- == new here == --> <ul><?php echo $row["ingredients"]?> </ul> </div> <br /> <h3 class="blue">Method</h3> <?php echo $row["instructions"]?> </div><!-- end of recipe-listing-item div --> <div class="post recipe-listing-item"></div><!-- end of recipe-listing-item div --> <?php } ?> <?php } else {?> <p>No weight with username<?php echo $username ?> in database.</p> <?php } ?> </div><!-- end of left-area --> <!-- LEFT AREA ENDS HERE --> <!-- end of content div --> <!-- ========== CONTENT AREA ENDS HERE ========== --> </div><!-- end of container div --> <div class="w-pet-border"></div> <!-- ============= CONTAINER AREA ENDS HERE ============== --> <?php include("footer.php");?> Quote Link to comment Share on other sites More sharing options...
Barand Posted May 3, 2013 Share Posted May 3, 2013 How are they stored at present? What is your table structure? Quote Link to comment Share on other sites More sharing options...
computermax2328 Posted May 3, 2013 Share Posted May 3, 2013 Yeah if you add ORDER BY to your query..... $sql = "select * from mr_recipes WHERE id='5' ORDER BY id DESC"; See this link for reference. Also, just picking this out our your query, is your id a string or an integer? If you put '' around it you are saying that it is a string. It depends on what you saved it in your database as. Give us more information on that as well. Quote Link to comment 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.