04192005 1013 GMT-6

Ok. Im working on this site and there is this very long application. 
Once you submit that, I have created a 'viewer' for the owner of the 
site to review those apps. Apps can be held for a long time. Some are 
rejected. When filled, they are removed - just like the rejected ones.

The owner wants to see all apps, starting with the first one. Now, I 
thought about sorting by date, but, because the apps can be updated, the 
date changes with every update. So, I went with the appid. Its 
sequential - just like the owner wants it to be.

I would start at the first one and go on to next and so on.

Now, you have to know that I do not have access to make changes to the 
db. I have suggested it time and again but the owner wants it a certain 
way.

If you have a better suggestion - PLEASE tell me.

Here is a piece of code from another list. It worked for one guy but Im 
having difficulty with it.

$q1 = "SELECT Max(clrId ) As prev from tblcolorpattern Where clrId <
$id";
$res = mysql_query($q1);
if($res)
{
      $num = mysql_num_rows($res);
      if($num)
      {
            $prev = mysql_result($res,0,0);
      }
}

this code give me id before the current id in DB

/************************************************/

$q2 = "SELECT Min(clrId ) As next from tblcolorpattern Where clrId >
$id";
$res = mysql_query($q2);
if($res)
{
      $num = mysql_num_rows($res);
      if($num)
      {
            $next = mysql_result($res,0,0);
      }
}
this code give me id after the current id in DB

I rewrote it so I could better understand it:

$sql = "SELECT MAX(appid) AS prev from application WHERE appid < = 
'".$appid."'";

$result = mysql_query($sql);

if ($result) {
    $num = mysql_num_rows($result);
    if ($num) {
       $prev = mysql_result($result, 0, 0);
    }
}

I must have misunderstood how to use it.

Wade


Jeromie Clark wrote:

>It might help if you explain what you're trying to do...
>
>I'm not getting why you're worried about the ID if it's arbitrary.  In 
>that instance, you'd probably want to perform a query that's ordered 
>around something you actually care about. The only time I'd see needing 
>the ID (which you can include in that query) is if you were going to 
>perform another action on a specific row (INSERT, DELETE) where you'd 
>want the ID in the WHERE clause.
>
>You wouldn't need to have the ID beforehand, because you're selecting 
>rows without consideration for their ID.
>
>-Jeromie
>
>  
>
>>04182005 1517 GMT-6
>>
>>Ok. Thanks for answering my question but I didnt answer my own question.
>>Let me ask another question then.
>>
>>I have a table that holds application data. The key is the appid. If 
>>after viewing the app it doesnt have what Im looking for, it might be 
>>deleted. So after a while you will have a table of applications that 
>>doesnt have consecutive appid's.
>>
>>My question is, how do you know what the next id will be if they are not 
>>in order?
>>
>>Wade
>>
>> 
>>
>>    
>>
>
>
>
>The PHP_mySQL group is dedicated to learn more about the PHP_mySQL web 
>database possibilities through group learning.  
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>
>  
>


[Non-text portions of this message have been removed]



The PHP_mySQL group is dedicated to learn more about the PHP_mySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to