MySQL Error

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

User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post by bawla »

w0000t it worked
User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post by bawla »

http://www.krunkdesigns.com/gtthing/gtthing2.php
enter wut ever you want and tell me if it works for you
User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post by bawla »

oh yeah go to http://www.krunkdesigns.com/gtthing/gtthing4.php after you fill it out
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

after 5 pages of thread on the topic, i would hope it worked.

:wink: :wink: :wink:
User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post by bawla »

lol, still not done, how do i get it to display top 10 or 20 entered
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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
User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post 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
coreycollins
Forum Commoner
Posts: 67
Joined: Sun Feb 01, 2004 1:04 pm
Location: Michigan

Post by coreycollins »

ASC
User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post 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
coreycollins
Forum Commoner
Posts: 67
Joined: Sun Feb 01, 2004 1:04 pm
Location: Michigan

Post by coreycollins »

yep you have to loop though grabbing a row at a time.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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
coreycollins
Forum Commoner
Posts: 67
Joined: Sun Feb 01, 2004 1:04 pm
Location: Michigan

Post 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.
User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post by bawla »

i though u said not too read that tutorial,

any suggestions on books?
coreycollins
Forum Commoner
Posts: 67
Joined: Sun Feb 01, 2004 1:04 pm
Location: Michigan

Post by coreycollins »

User avatar
bawla
Forum Contributor
Posts: 116
Joined: Fri Mar 19, 2004 9:15 am

Post 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
Post Reply