Jump to content

usual pagination problems


verny

Recommended Posts

Hi,

 

I am new in PHP and was given an assignment to split the results of an operation into various pages. No matter how hard I try I cannot link page numbers to relevant results page. In somebody is willing to, please give me a helping hand. My email is [email protected].

 

Thank you a lot!

 

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

<style>

.text {

font-family:Arial, Helvetica, sans-serif;

font-size:12px;

font-weight:bold;

width:200px;

border-style:dashed;

border-width:thin;}

.box {

width:50px;

background-color:#CCCCCC;

 

 

 

}

</style>

</head>

 

<body> <center>

 

<?php

$arr = array (

1 => "+",

2 => "-",

3 => "*",

4 => "/",

);

 

?>

 

<form  method="POST" target="_top" action="<?php $_SERVER['PHP_SELF'] ?>"  onsubmit="return operation(this);" class="text" > <br />

 Insert Nr. X : <input name="x" class="box" value="<?php echo isset($_POST['x']) ? $_POST['x'] : ""; ?>">  <br> <br />

 Insert Nr. Y : <input name="y" class="box" value="<?php echo  isset($_POST['y']) ? $_POST['y'] : ""; ?>"> <br><br />

 Select an Operator

<select name="op" class="box"  >

<?

 

  $flag = isset($_POST['op']);

 

foreach ($arr as $k => $v)

{

$s = ($flag && $_POST['op'] == $k) ? " selected" : "";

 

print "<option value='".$k."'".$s.">".$v."</option>";

}

?>

</select> <br> <br />

 

Items per Page <input name="n" class"box" value="<?php echo isset($_POST['n']) ? $_POST['n'] : "10"; ?>" >

 

<input type="hidden" name="_submit_check" value="1"/>

<input type="submit" name="submit" > <br />

</form>

<hr />

 

<?php

 

 

if (isset($_POST['_submit_check']))

{

$n1 = $_POST['x'];

$n2 = $_POST['y'];

    $nmax = $_POST['n'];

 

if (empty($n1) || empty($n2))

{

echo 'Please Fill All Required Fields!!!';

}

elseif (is_numeric($n1) && is_numeric($n2))

{

echo "<table border=\"1\" align=\"center\">";

echo "<tr><th>X</th>";

echo "<th>Y</th>";

echo "<th>Result</th></tr>";

 

$zz = $arr[$_POST['op']];

 

for ($i=1; $i<=$nmax; $i++)

{

        echo "<tr><td>";

        echo $n1;

        echo "</td><td>";

        echo $i;

        echo "</td><td>";

 

//echo opr($n1,$i);

eval("echo \$n1".$zz."\$i;");

 

        echo "</td></tr>";

}

 

echo "</table>";

}

else

echo 'Please insert Only Numbers!';

}

?>

 

 

</center>

 

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/42964-usual-pagination-problems/
Share on other sites

You need to pass the $page_number into the second page, then:

 

 


$pos = $page_number * 20; // <-- assume 20 items per page

for( $i=$pos; $i<=$pos+20; $i++)
{

 

You can pass the page number into the page with:

 

<a href="my_page.php?page=3">

 

then do:

 

$page_number = intval( $_GET['page'] );

 

monk.e.boy

 

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.