PHP split lines into pages -


currently, have code:

<?php    if (isset($_get['id'])) {     $itemid = $_get['id'];     $search = "$itemid";     $query = ucwords($search);     $string = file_get_contents('http://example.com/tools/newitemdatabase/items.php');     if ($itemid == "") {       echo "please fill out form.";     } else {       $string = explode('<br>', $string);       foreach ($string $row) {         preg_match('/^(.+)\s=\s(\d+)\s=\s(\d+)\s=\s(\d+)/', trim($row), $matches);         if (preg_match("/$query/i", "$matches[1]")) {           echo "<a href='http://example.com/tools/newitemdatabase/info.php?id=$matches[2]'>";           echo $matches[1];           echo "</a><br>";         }       }     }   } else {     echo "item not exist!";   } ?> 

what want take of results in line echo $matches[1]; , split between pages 5 lines on each page.

this example of happening:
http://clubpenguincheatsnow.com/tools/newitemdatabase/search.php?id=blue

so want split lines separate pages 5 lines on each.

for example:

  • http://example.com/tools/newitemdatabase/search.php?id=blue&page=1
  • http://example.com/tools/newitemdatabase/search.php?id=blue&page=2
  • etc.

you can index variable , print 5 results, this:

<?php if (isset($_get['id'])) {   $itemid = $_get['id'];   $search = "$itemid";   $query = ucwords($search);   $string = file_get_contents('http://clubpenguincheatsnow.com/tools/newitemdatabase/items.php');   if ($itemid == "") {     echo "please fill out form.";   } else {     $string = explode('<br>', $string);      // define how result going show     $numbertoshow = 5;      // detect page number (from 1 infinite)     if (isset($_get['page'])) {       $page = (int) $_get['page'];       if ($page < 1) {         $page = 1;       }     } else {       $page = 1;     }     // calculate start row.     $startrow = ($page - 1) * $numbertoshow;      // index use     $i = 0;     foreach ($string $row) {       preg_match('/^(.+)\s=\s(\d+)\s=\s(\d+)\s=\s(\d+)/', trim($row), $matches);       if (preg_match("/$query/i", "$matches[1]")) {         // if start row current row         //   , current row not more number show after start row         if ($startrow >= $i && $i < $startrow + $numbertoshow) {           echo "<a href='http://clubpenguincheatsnow.com/tools/newitemdatabase/info.php?id=$matches[2]'>";           echo $matches[1];           echo "</a><br>";         }         // acumulate index         $i++;       }     }   } } else {   echo "item not exist!"; }  ?> 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -