HELP! I'm having sorting problems.
Posted: Tue Jul 02, 2002 3:56 pm
Hey guys...haven't written in awhile...but now i come crawling back, lol.
I have a poetry site at http://oversoul.mine.nu/~brian/poetry/ and I'm having trouble.
see, when you go to view your peoms, i have them just listed, but i want the list sorted NEWEST FIRST. It's impossible to like asort s title though.
Here's the code, see if u can help me out:
How can i reverse sort theses? Thanks SO much!
I have a poetry site at http://oversoul.mine.nu/~brian/poetry/ and I'm having trouble.
see, when you go to view your peoms, i have them just listed, but i want the list sorted NEWEST FIRST. It's impossible to like asort s title though.
Here's the code, see if u can help me out:
Code: Select all
<?php
session_start();
mysql_connect("localhost:3306", "poet") && mysql_select_db("poetry")
or $failed = "Could not connect to database.";
include "tprint.php"; //includes the top of the page
if(session_is_registered("loggedin")) //check wether they're logged in
{
echo "<b>Total Poems:</b> ";
$listquery = "select count(1) from poems where user="$loggedin""; //
$listresult = mysql_query($listquery); // All of this connects to a DB table, etc
while ($row = mysql_fetch_assoc($listresult)) { //
$count = $rowї"count(1)"]; //Counts the number of entries to be displayed
echo $count; //echo's that count
if($count != "0") { echo "<br /><br />"; } //gives an error if there are no entries
$listquery = "select * from poems where user="$loggedin""; //
$listresult = mysql_query($listquery); // Connects to another table without a count
while ($row = mysql_fetch_assoc($listresult)) { //
$title = $rowї"title"]; //get the title of each poem in a loop
$num = $rowї"num"]; // get s the corrosponding number so that a link can be madfe with the GET method
echo "<a href="read.php?num=$num">$title</a><br />"; //makes the link
}
}
else
{
echo "<b>You must be logged in to view your poems.</b>"; //error if ur not logged in
}
include "bprint.php";
$prevurl = "mypoems.php";
session_register("prevurl");
?>How can i reverse sort theses? Thanks SO much!