Need Some Help

Discussion in 'PHP' started by Arber-B, Jul 7, 2009.

  1. #1
    I have a simple php script:
    <?php
    $result = mysql_query("SELECT * FROM characters");

    echo "<table border='1'>
    <tr>
    <th>Character Name</th>
    <th>Level</th>
    </tr>";

    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['level'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";

    *just an example*
    and I want to order each result from 1-50. How would I do that?
     
    Arber-B, Jul 7, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Try this:

    
    <?php
    $result = mysql_query("SELECT * FROM characters");
    
    echo "<table border='1'>
    <tr>
    <th>Character Name</th>
    <th>Level</th>
    </tr>";
    
    $count = 1;
    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $count . "</td>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['level'] . "</td>";
    echo "</tr>";
    $count++;
    }
    echo "</table>";
    
    PHP:
     
    jestep, Jul 7, 2009 IP
  3. Arber-B

    Arber-B Banned

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks it worked :)
     
    Arber-B, Jul 7, 2009 IP
  4. SeoHawk

    SeoHawk Banned

    Messages:
    510
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It works fine to me ;)
     
    SeoHawk, Jul 7, 2009 IP