Janj Posted January 28, 2013 Share Posted January 28, 2013 Hey there, I need some help figuring out how to do something. What I need is a way to recall the whole database in descending order by artnum (the number of each entry). artnum begins at 001 and continues 002 003 and so on. Then it echoes them like this: <div class="big"><a href="newsn.php?art=[iNSERT art_title_url HERE]">[iNSERT art_title HERE]</a></div> [iNSERT art_desc HERE]<br /><br /> I already know how to fill them in, I just don't know how to make it so that I have one for each entry, so it would be like: <div class="big"><a href="newsn.php?art=[iNSERT 002 art_title_url HERE]">[iNSERT 002 art_title HERE]</a></div> [iNSERT 002 art_desc HERE]<br /><br /> <div class="big"><a href="newsn.php?art=[iNSERT 001 art_title_url HERE]">[iNSERT 001 art_title HERE]</a></div> [iNSERT 001 art_desc HERE]<br /><br /> (the 001 and 002 are the artnum numbers) This is what I have so far, but I think I'm wrong: $result = mysql_query("SELECT * FROM articles ORDER BY artnum DESC"); while($row = mysql_fetch_array($result)) { $art_title=$row['art_title']; $art_title_url=$row['art_title_url']; $art_desc=$row['art_desc']; } The main thing about that code is I need a way to echo every piece of information. I'm sorry if you don't understand, it's sort of hard to explain. If you want, post here and I'll try to say it to where you'll understand. My MySQL version is 5.0.91-log Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/ Share on other sites More sharing options...
Barand Posted January 28, 2013 Share Posted January 28, 2013 echo is useful in such stuations Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/#findComment-1408626 Share on other sites More sharing options...
Janj Posted January 28, 2013 Author Share Posted January 28, 2013 I understand how to use echo, but what do I put in there? The whole MySQL statement? Sorry, I'm genuinely confused about this. Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/#findComment-1408627 Share on other sites More sharing options...
Jessica Posted January 28, 2013 Share Posted January 28, 2013 You echo what you want echoed.... What did you try? Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/#findComment-1408629 Share on other sites More sharing options...
Janj Posted January 28, 2013 Author Share Posted January 28, 2013 (edited) Well, I haven't tried anything, because I don't understand :/ I need to echo every single row. Is there an all-inclusive? Or do I echo this? $result = mysql_query("SELECT * FROM articles ORDER BY artnum DESC"); Edited January 28, 2013 by Janj Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/#findComment-1408630 Share on other sites More sharing options...
Barand Posted January 28, 2013 Share Posted January 28, 2013 like this while($row = mysql_fetch_array($result)) { $art_title=$row['art_title']; $art_title_url=$row['art_title_url']; $art_desc=$row['art_desc']; echo "<div class=\"big\"><a href=\"newsn.php?art=$art_title_url\">$art_title</a></div> $art_desc<br /><br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/#findComment-1408631 Share on other sites More sharing options...
Janj Posted January 28, 2013 Author Share Posted January 28, 2013 like this while($row = mysql_fetch_array($result)) { $art_title=$row['art_title']; $art_title_url=$row['art_title_url']; $art_desc=$row['art_desc']; echo "<div class=\"big\"><a href=\"newsn.php?art=$art_title_url\">$art_title</a></div> $art_desc<br /><br />"; } Thanks so much! I have it working now! Quote Link to comment https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/#findComment-1408632 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.