Hi everyone, I am trying to sort an array taken from an sql query by a particular field from the array. Basically I am developing my own crude PHP forums and wish to sort the threads a user has made by date and time so latest is first. I have taken a custom sort function to sort the array before looping through and printing the results. Thing is all it seems to do is remove the first entry.
Since the sort function needs to be outside the while loop, I have stored the array '$query' in the variable '$row'. Am i performing the sort on the wrong variable? Either way, what is the syntax for a while statement when I have already stored $query in $row? I am so used to doing it all in one line I am unsure how to seperate them so it works. Also I am not sure if the sort code is adapted to sort particlar fields in the database correctly, any help with this would be awesome, thanks.
function compare($x, $y)
if ( $x == $y )
else if ( $x < $y )
echo "Thread:".$count.". <a href ='showthread.php?thread_id=".$threadid."'>".$threadname."</a> Posted By: ".$threadauthor." at ".$time." on ".$date."<br />";
Any help is appreciated. Thanks.