|
-
Jul 25th, 2002, 03:37 PM
#1
Thread Starter
Hyperactive Member
PHP Help Please
I want to get results from MySQL database and display them like this:
http://www.tricksoft.net/php/DT/topscores.php
Thanks in advance!
--=-=-=-=-=
The weirdest thing just happened to me. I came back to the forums and it said I was not logged in so I tried and it was an invalid account so I re-registered witht he same username and it workked lol. I was just here yesterday.
=--=-=-=-=-=
Kevin Carpenter
Currently Working in the CAOS (CA Operating System) Group
-
Jul 25th, 2002, 03:50 PM
#2
PowerPoster
Off the top of my head...
PHP Code:
<?php
// connect to db
$db = mysql_connect('localhost', 'username', 'password');
mysql_select_db('dbname', $db);
// query db
$scores_result = mysql_query('SELECT * FROM scores ORDER BY score DESC');
$rank = 0;
// loop through returned rows
while ($scores = mysql_fetch_array($scores_result)) {
// print row
$rank++;
print $rank.' ';
printf ("%s", $scores['name']);
print ' ';
printf ("%s", $scores['score']);
print '<br>';
}
?>
-
Jul 25th, 2002, 03:59 PM
#3
Thread Starter
Hyperactive Member
Sorry, I should have explained. I know how to get the results...But I want the colors to change for every result. Back and forth
Kevin Carpenter
Currently Working in the CAOS (CA Operating System) Group
-
Jul 25th, 2002, 04:16 PM
#4
PowerPoster
I see
Try something like this...
PHP Code:
$bgcolour = '#FFFFFF';
// print each row
while (...blah blah blah...) {
// alternate colour
if ($bgcolour = '#FFFFFF') {
$bgcolour = '#000000';
} else {
$bgcolour = '#FFFFFF';
}
}
Last edited by chrisjk; Jul 25th, 2002 at 04:26 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|