Jump to content

[SOLVED] return query pagination


DarkPrince2005

Recommended Posts


The attached code is suppose to query a database and return records between two dates and update the pagination links.

 

It works at first, but as soon as I click on a pagination link it re-queries the database and returns all of the records.

 

Can somebody please advise me how to resolve this problem.

 

<?php

 

mysql_connect("localhost","root","");

mysql_select_db("npa");

 

$perpage = 1;

$lynx = $html = "";

$startat = $_REQUEST


* $perpage;

 

$q = mysql_query("select count(File_Ref) from dis where Date_Recieved between '$_POST[date1]' and curdate()");

$row = mysql_fetch_array($q);

$pages = ($row[0] + $perpage - 1) / $perpage;

 

$q = mysql_query("select * from dis where Date_Recieved between '$_POST[date1]' and curdate() order by File_Ref desc limit $startat,$perpage");

 

while ($row = mysql_fetch_assoc($q)) {

$text = strip_tags($row[entry_text]);

$text = substr($text,0,300);

$html .= "<center><form>

<table cellpadding='0' border='0' cellspacing='0'><tr>

<td valign='top'><table width='400'>

<tr><td><b>File Ref</td><td> </td>

<td>$row[File_Ref]</td></tr>

<tr><td><b>Employee Firstname</td><td> </td>

<td>$row[Employee_Firstname]</td></tr>

<tr><td><b>Employee Lastname</td><td> </td>

<td>$row[Employee_Lastname]</td></tr>

<tr><td><b>Persal Number</td><td> </td>

<td>$row[Persal_Number]</td></tr>

<tr><td><b>Occupation</td><td> </td>

<td>$row[Occupation]</td</tr>

<tr><td><b>Level</td><td> </td>

<td>$row[Level]</td</tr>

<tr><td><b>Gender</td><td> </td>

<td>$row[Gender]</td</tr>

<tr><td><b>Race</td><td> </td>

<td>$row[Race]</td</tr>

<tr><td><b>Suspension</td><td> </td>

<td>$row[suspensions]</td</tr>

<tr><td><b>Period</td><td> </td>

<td>$row[Period]</td></tr>

<tr><td><b>Date Recieved</td><td> </td>

<td>$row[Date_Recieved]</td</tr>

<tr><td><b>Unit</td><td> </td>

<td>$row[unit]</td</tr>

<tr><td><b>Region</td><td> </td>

<td>$row[Region]</td</tr>

<tr><td><b>Date Of DC</td><td> </td>

<td>$row[Date_Of_DC]</td</tr>

<tr><td><b>Status</td><td> </td>

<td>$row[status]</td</tr>

<tr><td><b>Category</td><td> </td>

<td>$row[Category]</td></tr>

<tr><td><b>Outcome</td><td> </td>

<td>$row[Outcome]</td></tr></table></td><td> </td><td valign='top'><table width='400'>

<tr><td valign='top'><b>Status Report</td><td> </td>

<td width='250'>$row[status_Report]</td></tr>

<tr><td>$r</td></tr>

</table></table>

</form>";

};

echo "$r";

for ($k=0; $k<$pages; $k++) {

if ($k != $_REQUEST


) {

$lynx .= " <a href=$PHP_SELF"."?page=$k>".($k+1)."</a>";

} else {

$lynx .= " <b>--".($k+1)."--</b>";

}

}

?>

<html><head><title></title><link rel='stylesheet' href='stylesheet.css' type='text/css'>

<style>

 

a:link{font-family:'Times New Roman';

font-size:10pt;

color:'#ffffff';

font-weight:700;

text-decoration:none;

}

 

a:visited{font-family:'Times New Roman';

font-size:10pt;

color:'#ffffff';

font-weight:700;

text-decoration:None;

}

 

a:hover{font-family:'Times New Roman';

font-size:10pt;

text-decoration:none;

color:'#B37A04';

font-weight:700;

}

 

a:active{font-family:'Times New Roman';

font-size:10pt;

color:'#ffffff';

font-weight:700;

}

 

</style></head><body bgcolor='#FDCC67' topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0'>

<center><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">

<tr><td valign='top' width='140' bgcolor='#000000'><br>

<a href='home.html'>Home</a><br><br>

<a href='viewdate.php'>View Records</a><br><br>

<a href='add.html'>Add Record</a><br><br>

<a href='edit1.php'>Edit Record</a><br><br>

<a href='deletedate.php'>Delete Record</a><br><br>

<a href='report.php'>View Report</a><br><br>

<a href='q.php'>Query Report</a><br><br>

<a href="search1.php">Search</a></td><td valign="top" align="center"><table><tr>

<td align="right" valign="top"><form action="search2.php" method="post"><b>Search by Persal Number or Employee Lastname:</b>  <input type="text" name="search"> <input type="submit" value="Search"></form></td></tr>

<tr><td align="center" valign="top"><h1>View Disciplinary Records</h1></td></tr>

<tr><td align="center" valign="top"><?= $lynx ?></td></tr>

 

<tr><td align="center" valign="top"><br><?= $html ?></td></tr></table></td></tr></table>

</body>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.