Results 1 to 4 of 4

Thread: PHP Help Please

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296

    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

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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>';
    }

    ?>

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296
    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

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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
  •  



Click Here to Expand Forum to Full Width