Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Database table out of order.

    PHP Code:
    $i=0;
    while ($i < $num) {
    $Id=mysql_result($result,$i,"Id");
    $Type=mysql_result($result,$i,"Type");
    $Size=mysql_result($result,$i,"Size");
    $Color=mysql_result($result,$i,"Color");
    $fname=mysql_result($result,$i,"fname");
    $lname=mysql_result($result,$i,"lname");
    $email=mysql_result($result,$i,"email");
    $phone=mysql_result($result,$i,"phone");
    $street=mysql_result($result,$i,"street");
    $city=mysql_result($result,$i,"city");
    $state=mysql_result($result,$i,"state");
    $zip=mysql_result($result,$i,"zip");
    $special=mysql_result($result,$i,"special");
    $datetime=mysql_result($result,$i,"datetime");
    $filled=mysql_result($result,$i,"filled");
    ?>

    <tr bgcolor=<? echo ($i%2) ? "$color1" "$color2" ;?>
    <td width="15"><div align=center><input type=radio name="<? echo "$temp" ?>" value="<? echo "$temp" ?>"></div></td>
    <td bgcolor=<? echo ($i%2) ? "$color3" "$color4" ;?> width="1"><font color="<? $colorID ?>"><? echo "$bold$Id$boldoff"?></font></td>
    <td width="100"><? echo "| $Type"?></td>
    <td width="100"><? echo "| $Size"?></td>
    <td width="100"><? echo "| $Color"?></td>
    <td width="150"><? echo "| $fname"?></td>
    <td width="200"><? echo "| $lname"?></td>
    <td width="300"><? echo "| $email"?></td>
    <td width="150"><? echo "| $phone"?></td>
    <td width="400"><? echo "| $street"?></td>
    <td width="150"><? echo "| $city"?></td>
    <td width="100"><? echo "| $state"?></td>
    <td width="75"><? echo "| $zip"?></td>
    <td width="300"><? echo "| $special"?></td>
    <td width="200"><? echo "| $datetime"?></td>
    <td width="100"><? echo "| $filled"?></td>
    </tr>
    <?php
    ++$i;
    }
    How can i get this to write the table in order of $Id, from largest to greatest? Right now it writes $Id 17, then 15 down to 11, then 18 up to 24. Its realy screwy.
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    PHP Code:
    $query="SELECT * FROM Orders ORDER BY Id DESC"
    Thats how to fix it for those who brought this up on search.

    Found it by way of help from a friend.
    If I'm postin here, I NEED YOUR HELP!!

  • #3
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts
    you may also wish to use mysql_fetch_assoc for legibility purposes.

    -Celt


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •