Results 1 to 4 of 4

Thread: step through records [cont.]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    step through records [cont.]

    I had a problem before where I stepped through various records. The solution was to just find the next/previous ID in my identifier column and display that data.

    However, now I'm implementing a search function. I can grab all of the IDs that are returned from the search function, but how do I keep track of them and find the next/previous one when I refresh the page? I'm totally lost on this one.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    anyone?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Do you have any code that you're using right now (that isn't working)? Or are you still at the "where to start" point?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Ok, here is the code for how I get the IDs that I need:

    PHP Code:
    //--- get the maximum id ---------
        
    $wclause 0;
        
    $maxid=0;
        
    $query2 "SELECT ID FROM [Cell Equipment Complete]";
        if(isset(
    $_GET['CELLNUMBER']))
        {
            if(
    $_GET['CELLNUMBER'] != '*')
            {
                
    $query2 .= " WHERE CELLNUMBER = " $_GET['CELLNUMBER'];
                
    $wclause 1;
            }
            if(
    $_GET['TAG_ID'] != '*')
            {
                if(
    $wclause == 0)
                {
                    
    $query2 .= " WHERE TAG_ID = " $_GET['TAG_ID'];
                    
    $wclause 1;
                }
                else
                    
    $query2 .= " AND TAG_ID = " $_GET['TAG_ID'];
            }
            if(
    $_GET['TAG_NUM'] != '*')
            {
                if(
    $wclause == 0)
                    
    $query2 .= " WHERE TAG_NUM = " $_GET['TAG_NUM'];
                else    
                    
    $query2 .= " AND TAG_NUM = " $_GET['TAG_NUM'];
            }
        } 
    // end isset check
        
    $result2 mssql_query($query2);         
        
    $maxid mssql_num_rows($result2); 

    and here is the code for moving forward one record before I added the search function:
    PHP Code:
     switch($_GET['dir'])
    {
    //----------------Go forward one record----------------------------------------------
    //---------------------------------------------------------------------------------------
    case "next":

        
    $go=0;
        while(
    $go<1)
        {
            
    // --- grab the next valid id
            
    $id++;
            if(
    $id $maxid)
            {
                
    $id=0;
            }
            else
            {
                
    $query2 "SELECT CELLNUMBER FROM [Cell Equipment Complete] WHERE ID = " $id;
                
    $result2 mssql_query($query2);         
                
    $row2 mssql_fetch_array($result2);        
                if(
    $row2[0] != "")
                    
    $go=1;
            }
        }
    break; 
    I'm just not sure how to modify that to grab the next one out of the results that are returned from the first bit of code.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

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



Click Here to Expand Forum to Full Width