I think it's a wrapping thing. If reaching the end start from beginning.

----- Original Message ----- 
From: "Wade" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 18, 2005 10:57 PM
Subject: [php-list] Next & Previous Records


> 04182005 1551 GMT-6
>
> I want to find the next and previous records in a list of records. I did
> a search and found this code:
>
> $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
>
> But Im a but unsure of it all so I would like some help with it. Im
> going to change it to what I think I would write:
>
> $query = "$SELECT MAX(appid) AS prev FROM Application WHERE appid <
> '".$appid."'";
>
> $result = mysql_query($query);
>
> if($result) {
>    $num = mysql_num_rows($result);
>
>    if($num) {
>       $next = mysql_result($result,0,0);
>    }
> }
>
> Ok. Im selecting the next larger appid (application id) and assigning it
> to 'prev'.
>
> Then, im assigning the appid to $num.
> I dont understand the next part at all = ($result,0,0);
>
> Wade
>
>
> [Non-text portions of this message have been removed]
>
>
>
> Community email addresses:
>  Post message: [email protected]
>  Subscribe:    [EMAIL PROTECTED]
>  Unsubscribe:  [EMAIL PROTECTED]
>  List owner:   [EMAIL PROTECTED]
>
> Shortcut URL to this page:
>  http://groups.yahoo.com/group/php-list
>
>
>
> --------------------------------------------------------------------------------
> Yahoo! Groups Links
>
>  a.. To visit your group on the web, go to:
>  http://groups.yahoo.com/group/php-list/
>
>  b.. To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
>
>  c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
> 



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

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

<*> 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