Hi,

Using the following function I can present any query in a table. However
some of the results are very large and I would like to limit all results to
1000 rows. So I am trying to paginate the results. However the page that
calls these queries uses form elements to create the query. So I need to be
able to add links to the top of the query result i.e. previous and next, and
I need to resubmit the $_POST variables to create the query again.

Thanks for any advice offered.

 function doQuery($query){
  if(!($result = mysql_query(stripslashes($query)))){
   echo '<br><br><div align="center">'.mysql_error().'</div>';
   exit;
  } else {
   $num_fields = mysql_num_fields($result);
   $num_rows = mysql_num_rows($result);
   if ($num_fields > 0 && $num_rows > 0){
    echo '
     <table border="1" cellspacing="0" cellpadding="2"
bordercolor="#FFFFFF">
      <tr>';
    for($i = 0; $i < mysql_num_fields($result); $i++){
     echo '<td bgcolor="#ffffff"
align="center"><strong>'.mysql_field_name($result, $i).'</strong></td>';
    }
    for($i = 0; $i < mysql_num_rows($result); $i++){
     echo '<tr>';
     $row_array = mysql_fetch_row($result);
     for($j = 0; $j < mysql_num_fields($result); $j++){
      echo '<td bgcolor="#eeeeee" align="center">'.$row_array[$j].'</td>';
     }
     echo '</tr>';
    }
    echo '</table>';
   } else {
    echo '<br><br><div align="center">No data in table</div>';
   }
  }
 }

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

Reply via email to