Hi all,
Hope everyone is doing great.
I have created a reporting page called “summary.php” which can run different queries based on a selection from another page. Everything works well, the only thing I can’t figure out is the pagination URL.
Example:
When I request a list of all patients that need pre_medication I get the correct number of results and pages, but when I go to page 2, everything is blank. I know it has to do with $targetpage. Any help is much appreciated.
Here’s the part of the code that I’m having problems with. If you need to see the entire code I can include that as well. Thanks in advance!
[php]
/// query for patients in need of pre_med
if(isset($_POST[‘pre_medication’]) )
{
$query = “SELECT COUNT(id) as num FROM $tbl_name where pre_med=‘YES’”;
$targetpage = "summary.php?"; // URL for search string
//// count the results from the query above
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$limit = 2; //how many items to show per page
$page = $_POST['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
echo “
Patient Summary Report (Patients Needing Pre-medication)
”;$query=“SELECT id,first_name,last_name,home_phone,mobile FROM $tbl_name where pre_med=‘YES’ LIMIT $start, $limit”;
}
////// end pre_med section
[/php]