Oh btw, you will have to remove those isString and isint functions.. they are other parts of my library that just check the type of a variable...
and log a message through an error handling system I've set up.. I'd have the library up now but it's not that well commented.. Josh. On February 12, 2003 01:30 pm, Joshua Moore-Oliva wrote: > Try this function... it's one part of a php class I've been thinking about > making open-source. Give it any sql statement and a page (0 based for the > page) and a number of records for a page and you are set. > > I've only tested this on postgresql. > > function pageSql( $sql, $page, $recs_per_page ) { > > $this->isString( '$sql', $sql ); > $this->isInt( '$page', $page ); > $this->isInt( '$recs_per_page', $recs_per_page ); > > $sql = trim( $sql ); > $sql = substr( $sql, strlen( "SELECT" ) ); > > if ( $sql[strlen($sql)-1] != ";" ) { > $sql .= ";"; > } > > $sql = sprintf( "CREATE TEMP SEQUENCE temp_sequence;\n" > . "CREATE TEMP TABLE temp_table AS\n" > . " SELECT nextval( 'temp_sequence' ) AS temporary_idASDF, > %s\n" > . "SELECT ( SELECT COUNT(*) >FROM temp_table\n" > . " > WHERE temporary_idASDF > %d ) AS recs_remaining, \n" > . " * FROM temp_table\n" > . " WHERE temporary_idASDF > >%d\n" > . " AND temporary_idASDF < %d\n" > . " ORDER BY temporary_idASDF;" > > , $sql > , ( $page + 1 ) * $recs_per_page + 1 > , $page * $recs_per_page > , ( $page + 1 ) * $recs_per_page + 1 ); > > return $sql; > } > > On February 12, 2003 11:58 am, Lucas Lain wrote: > > Hi.. i'm new at this mailing list and you can say that i'm a newbie in > > Php programming :) > > i dont know how to pass a connection to a database between pages. I want > > to show the results in multiple pages with a unique connection. > > can anyone help me? > > Thanks in advance. > > Lucas > > > > -- > > Lucas Lain > > [EMAIL PROTECTED] > > Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php