PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ScOrPi
Forum Commoner
Posts: 44 Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ
Post
by ScOrPi » Thu Aug 12, 2010 7:49 am
Hi all ,
iam making script that's contain comments
but the problem is that the new comment always add at the bottom .. how can i make it at the top
iam using this code
Code: Select all
while ($mem = mysql_fetch_array($re)) {
print "<table width=100% border=0 cellspacing=0 cellpadding=0>";
print "<tr>";
print "<td class=comment_bg>كتبها ". $mem['commenter']. "</td>"
print "</tr>";
print "<tr>";
print "<td class=comment_bg>".$mem['comment']."</td> </tr></table><br /><br />";
}
shawngoldw
Forum Contributor
Posts: 212 Joined: Mon Apr 05, 2010 3:38 pm
Post
by shawngoldw » Thu Aug 12, 2010 8:34 am
You need to use ORDER BY somefield DESC at the end of your mysql statement. The field is probably id or if you have an auto-incrementing primary field, whatever its called.
Shawn
ScOrPi
Forum Commoner
Posts: 44 Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ
Post
by ScOrPi » Thu Aug 12, 2010 9:50 am
Thank u i got it
after Query the comment i'd Query
Code: Select all
$query = "ALTER TABLE `$mem` ORDER BY `comments` DESC";
Thanks Dude it's work !
ScOrPi
Forum Commoner
Posts: 44 Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ
Post
by ScOrPi » Sat Aug 14, 2010 3:53 pm
Sorry .. But must i put it every time befor printing the tables from mysql ?
arrielmabale
Forum Newbie
Posts: 15 Joined: Fri Aug 13, 2010 3:57 pm
Location: Dubai
Post
by arrielmabale » Sat Aug 14, 2010 4:22 pm
ScOrPi wrote: Sorry .. But must i put it every time befor printing the tables from mysql ?
Yes I think you have to, Or you can specify an extra field that will identify weather its a comment or not then
filter your query on display