Page 5 of 5
Posted: Sun Mar 21, 2004 1:04 pm
by bawla
w0000t it worked
Posted: Sun Mar 21, 2004 1:05 pm
by bawla
http://www.krunkdesigns.com/gtthing/gtthing2.php
enter wut ever you want and tell me if it works for you
Posted: Sun Mar 21, 2004 1:09 pm
by bawla
Posted: Sun Mar 21, 2004 1:10 pm
by tim
Posted: Sun Mar 21, 2004 1:12 pm
by bawla
lol, still not done, how do i get it to display top 10 or 20 entered
Posted: Sun Mar 21, 2004 1:41 pm
by tim
top 10? or just 10 rows?
top 10 would look like:
Code: Select all
<?php
$sql = "SELECT * FROM table_name ORDER BY points/whatever DESC LIMIT 10";
// if you want just 10
$sql = "SELECT * FROM table_name LIMIT 10";
?>
and to claifiy, points/whatever is whatever it is your basing your info on to arrange from lowest -> highest
Posted: Sun Mar 21, 2004 2:22 pm
by bawla
but i want it to be from highest to lowest would that be
Code: Select all
<?php
$sql = "SELECT * FROM table_name ORDER BY points/whatever ACEN LIMIT 10";
?>
or how ever you do accending
Posted: Sun Mar 21, 2004 2:30 pm
by coreycollins
ASC
Posted: Sun Mar 21, 2004 2:53 pm
by bawla
Code: Select all
<?php
$db = mysql_connect("localhost", "krunk_gtstat", "gtstat");
mysql_select_db("krunk_gtstat",$db);
$result = mysql_query("SELECT * FROM stat ORDER BY percent ASC LIMIT 10",$db);
printf("Username: %s<br>\n", mysql_result($result,0,"username"));
printf("Percentage: %s<br>\n", mysql_result($result,0,"percent"));
?>
it only displays one of the "usernames,percents"
http://www.krunkdesigns.com/gtthing/gtthing3.php
Posted: Sun Mar 21, 2004 2:58 pm
by coreycollins
yep you have to loop though grabbing a row at a time.
Posted: Sun Mar 21, 2004 2:59 pm
by tim
lol...
you need a loop function so it displays all data in the db.
I assume you didnt bother looking at the tutorial I gave you huh? Cause most of your questions would already been answered.
heh
http://us4.php.net/manual/en/control-st ... .while.php
Posted: Sun Mar 21, 2004 3:00 pm
by coreycollins
http://hotwired.lycos.com/webmonkey/99/21/index4a.html
I would suggest look thought google for tips for all of this too and purchasing a decent PHP and mySQL book.
Posted: Sun Mar 21, 2004 3:04 pm
by bawla
i though u said not too read that tutorial,
any suggestions on books?
Posted: Sun Mar 21, 2004 3:11 pm
by coreycollins
Posted: Sun Mar 21, 2004 5:01 pm
by bawla
ok this is wut i got
Code: Select all
<?php
$db = mysql_connect("localhost", "krunk_gtstat", "gtstat");
mysql_select_db("krunk_gtstat",$db);
$result = mysql_query("SELECT * FROM stat",$db);
while ($myrow = mysql_fetch_row($result)) {
printf("Username: %s<br>\n", mysql_result($result,0,"username"));
printf("Percentage: %s<br>\n", mysql_result($result,0,"percent"));
}
echo "\n";
?>
but it just keeps looping and never stops, did i miss something?
for an example got to
http://www.krunkdesigns.com/gtthing/gtthing3.php