Jump to content

coding for returning results 30 at a time...


jtracey0380

Recommended Posts

I'll try this one more time. My code returns the results from a query. it also returns the number of results. what i would like the code to do is return 30 results at a time. i need the code to write links for the rest of the results. if my code returns 500 results how would i then list them 30 at a time.

<?php

$db = mysql_connect('jtracey.fatcowmysql.com', 'bookorama', 'xxdustin');

  if (!$db)
  {
     echo 'Error: Could not connect to database.  Please try again later.';
     exit;
  }

  mysql_select_db('jtbookorama');
  $query = "SELECT `page_info` FROM `pages` ORDER BY `page_name` ASC LIMIT 5 , 5";
  $result = mysql_query($query);

  $num_results = mysql_num_rows($result);

  echo '<p>Number of items found: '.$num_results.'</p>';

  for ($i=0; $i <$num_results; $i++)
  {
     $row = mysql_fetch_array($result);

     
     echo stripslashes($row['page_info']);
     echo '<br />';

   }

?>

I'll try this one more time. My code returns the results from a query. it also returns the number of results. what i would like the code to do is return 30 results at a time. i need the code to write links for the rest of the results. if my code returns 500 results how would i then list them 30 at a time.

 

<?php

 

$db = mysql_connect('mysql_server', 'username', 'password');

 

  if (!$db)

  {

    echo 'Error: Could not connect to database.  Please try again later.';

    exit;

  }

 

  mysql_select_db('jtbookorama');

  $query = "SELECT `page_info` FROM `pages` ORDER BY `page_name` ASC LIMIT 5 , 5";

  $result = mysql_query($query);

 

  $num_results = mysql_num_rows($result);

 

  echo '<p>Number of items found: '.$num_results.'</p>';

 

  for ($i=0; $i <$num_results; $i++)

  {

    $row = mysql_fetch_array($result);

 

   

    echo stripslashes($row['page_info']);

    echo '<br />';

 

  }

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.