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
Little Spy
Forum Commoner
Posts: 31 Joined: Thu Oct 10, 2002 8:18 pm
Contact:
Post
by Little Spy » Thu Oct 10, 2002 8:18 pm
i am making an aim subprofile script to set the mood for you, and an trying to get the array to output all the people's screen names in reverse table order because i want the most recent users (the one's most recently) added to the table to be displayed
Code: Select all
$sql = mysql_query("SELECT * FROM userinfo");
while ($row = mysql_fetch_assoc($sql)) {
$whoviewed = $rowї'sn'];
echo $whoviewed . "<br>";
}
Currently it is outputing the screen names in table order.
Here is my table setup
id INT(3) NOT NULL auto_increment,
sn MEDIUMTEXT,
dateofv MEDIUMTEXT,
hits INT(5) DEFAULT 1,
PRIMARY KEY(id)
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Thu Oct 10, 2002 8:26 pm
do this:
Code: Select all
$sql = mysql_query("SELECT * FROM userinfo");
while ($row = mysql_fetch_assoc($sql)) {
$whoviewedї] = $rowї'sn'];
}
$whoviewed = array_reverse($whoviewed);
foreach($whoviewed as $sn){
echo $sn."/n<br>";
}
Little Spy
Forum Commoner
Posts: 31 Joined: Thu Oct 10, 2002 8:18 pm
Contact:
Post
by Little Spy » Thu Oct 10, 2002 8:29 pm
thnx that works but i found a little easier way from a freind to just to do this in the query
Code: Select all
$sql = mysql_query("SELECT * FROM userinfo ORDER BY ID DESC");
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Thu Oct 10, 2002 9:16 pm
Little Spy wrote: thnx that works but i found a little easier way from a freind to just to do this in the query
Code: Select all
$sql = mysql_query("SELECT * FROM userinfo ORDER BY ID DESC");
yeah, about 5 seconds after i posted i thought of that way as well.
they both work, and it's good to know both, you might need array_reverse() in the future