Would using sort($result); solve the problem? I believe the default sort
order is ascending. Try using sort($result) before your while($myrow =
mysql_fetch_array($result)) statement and see if that fixes things.

I also noticed that you don't use an ORDER BY clause in your sql statement,
but if the query works in MySQL, then I guess it's not necessary?

Good Luck
Rich

-----Original Message-----
From: Blaine D. Dinsmore [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 12:34 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] ID numbers not sorting Properly


I'm using MySQL and I have noticed that my primary key which are
autoincrementing numbers do not sort properly when pulling the results to
the browser. They are showing consecutively all the way until 150 then they
start going backwards for example:
157
156
155
154
159
160
161
162
163
When I do a query in MySQL they are sequenced correctly but using the php
mysql_fetch_array() I get this crazy numbering sequence. Does anyone know
what this could be?

Here is my code:

<body bgcolor="#000000" text="#FFFFFF" link="#99FF33" vlink="#FFFF00"
alink="#99CCFF">
<FONT FACE=ARIAL>
<?php
 include('functions.php');

 $dbase="lims_issues";
If ($_GET[order] == 1) {
$sql= "SELECT probid,resolved,loggerid,DATE_FORMAT(logdate,'%m-%d-%Y') AS
date,priority,screen,descript,notes" .
    " FROM bugs";
}

If ($_GET[order] == 2) {
$sql= "SELECT probid,resolved,loggerid,DATE_FORMAT(logdate,'%m-%d-%Y') AS
date,priority,screen,descript,notes" .
    " FROM bugs WHERE resolved=0";
}

If ($_GET[order] == 3) {
$sql= "SELECT probid,resolved,loggerid,DATE_FORMAT(logdate,'%m-%d-%Y') AS
date,priority,screen,descript,notes" .
    " FROM bugs WHERE resolved=1";
}

If ($_GET[order] == 4) {
$sql= "SELECT probid,resolved,loggerid,DATE_FORMAT(logdate,'%m-%d-%Y') AS
date,priority,screen,descript,notes" .
    " FROM bugs WHERE discussed=0";
echo("<font size=5><b>Issues Not Disscussed With Beckman</b></font>");
}

If ($_GET[order] == 5) {
$sql= "SELECT probid,resolved,loggerid,DATE_FORMAT(logdate,'%m-%d-%Y') AS
date,priority,screen,descript,notes" .
    " FROM bugs WHERE discussed=1";
echo("<font size=5><b>Issues Disscussed With Beckman</b></font>");
}
mysqlconn($dbase,$sql);


   while( $myrow = mysql_fetch_array($result) ){
            ?>
<Table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
collapse" bordercolor="#777777" width="100%">
  <TR bgcolor="#006600">
    <TD colspan=3>
      <?php echo("<b>Issue ID: </b>" . "<a href=modify.php?getprobid="
.$myrow["probid"] .">" . $myrow["probid"] . "</a>"); ?>
      </TD>
  <?php
   if ($myrow["resolved"] == '1') {
   Echo("<TD bgcolor=#006600>");
   Echo("<b><font color=#FFFFFF>Resolved</font></b>");
   Echo("</TD>");



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to