Page 1 of 1
Reverse
Posted: Sun Nov 10, 2002 7:48 pm
by Silver_Eclipse
does anyone here know how i would print out something in reverse order?
say i have a list of numbers that is constantly getting larger, how would i print those numbers out from greatest to least instead of least to greatest?
(basically i have info in a database that is numbered and i need to print them all out but in reverse order)
Posted: Sun Nov 10, 2002 8:19 pm
by hob_goblin
it's in mysql?
try a query like
SELECT * FROM table ORDER BY column DESC
now, assuming "column" is an integer or something, it will pick out the largest number first, and then descend down to the smallest.
Posted: Mon Nov 11, 2002 3:13 pm
by Silver_Eclipse
Yeah works just fine now, thanks. Another question though, i have a login system setup using cookies, but even if they input an invalid username and password it still sends them a cookie and i have to set the cookies before i can do anything else. Is there a way to make it so that if they input an invalid name and pass then don't send the cookie?
Posted: Mon Nov 11, 2002 6:05 pm
by Silver_Eclipse
or maybe delete the cookie right after the login if the name and password are invalid?
Posted: Mon Nov 11, 2002 9:46 pm
by hob_goblin
Code: Select all
$qry = mysql_query("SELECT * FROM table WHERE username = '$username' AND password = '$password'");
if(mysql_num_rows($qry) == "1"){
setcookie();
} else {
echo "Invalid input";
}
make sure to do error checking on $username and $password first (like making sure they are just letters and numbers and whatever... you can use regular expressions to do this)
Posted: Tue Nov 12, 2002 5:25 am
by volka
or use
mysql_escape_string on all user input. May they type as much malicious input as they want

Posted: Tue Nov 12, 2002 4:55 pm
by Silver_Eclipse
Code: Select all
$qry = mysql_query("SELECT * FROM table WHERE username = '$username' AND password = '$password'");
if(mysql_num_rows($qry) == "1"){
setcookie();
} else {
echo "Invalid input";
}
yes but i have to use
to select the database adn tehn i can't set the cookie because it says headers are already sent
Posted: Tue Nov 12, 2002 5:02 pm
by hob_goblin
select_db should not be outputting headers, check for something else.