Jump to content

need code to get the remainder of items - five at a time


jtracey0380

Recommended Posts

below is the basic code I am using - it  counts the items that were fetched from the db - it lists the 5 items. HOW DO I GET THE REMAINDER OF ITEMS TO SHOW UP 5 AT A TIME?

 

Thank you so much. :)

 

 

<?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('db_name');

  $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 />';

 

  }

 

?>

 

 

 

below is the basic code I am using - it  counts the items that were fetched from the db - it lists the 5 items. HOW DO I GET THE REMAINDER OF ITEMS TO SHOW UP 5 AT A TIME?

 

Thank you so much. :)

 

 

<?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('db_name');

  $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.