Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/273711-retrieve-database-descending-order/
Share on other sites

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 />";
}

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.