<?php
/* call this script "advs.php" */
//if(!$c) {
if(!$_GET['c']) {
//"c" variable to $_GET['c'] and the "all" "any" and "none" variables to $_POST['all']
?>
<?php
$all= $_POST['all'] ;
$any= $_POST['any'] ;
$none=$_POST['none'] ;
echo "<b>Let's see the POST/GET data:</b><br/>";
echo "All = ".$all." | Any = ".$any." | None = ".$none."<br/>";
//this makes sure the page number isn't below one, or more than our maximum pages
$pageno = $_GET['pageno'];
if ($pageno > $lastpage) {
$pageno = $lastpage;
}
if ($pageno < 1) {
$pageno = 1;
}
echo "Here's the page number we got: ".$pageno."<br/><br/>";
mysql_connect("localhost","root","rootroot");
MySQL_select_db("coas5");
if((!$all) || ($all == "")) { $all = ""; } else { $all = "+(".$all.")"; }
if((!$_POST['all'] ) || ($_POST['all'] == "")) { $_POST['all'] = ""; } else { $_POST['all'] = "+(".$_POST['all'] .")"; }
if((!$any) || ($any == "")) { $any = ""; }
if((!$none) || ($none == "")) { $none = ""; } else { $none = "-(".$none.")"; }
$query = " SELECT count(*),
MATCH(subject, learningArea, noofstudents, topic, ability) AGAINST ('$all $none $any' IN BOOLEAN MODE)
FROM lesson
WHERE MATCH(subject, learningArea, noofstudents, topic, ability) AGAINST ('$all $none $any' IN BOOLEAN MODE) AND lesson.verified= 'yes' " ;
echo "<b>Query passed in:</b>".$query."<br/><br/>";
$artm1 = MySQL_query($query);
$query_data = mysql_fetch_row($artm1);
$numrows = $query_data[0];
$rows_per_page = 2;
$lastpage = ceil($numrows/$rows_per_page);
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
$pageno = $lastpage;
}
if ($pageno < 1) {
$pageno = 1;
}
//This sets the range to display in our query
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
$query = " SELECT *,
MATCH(subject, learningArea, noofstudents, topic, ability) AGAINST ('$all $none $any' IN BOOLEAN MODE)
FROM lesson
WHERE MATCH(subject, learningArea, noofstudents, topic, ability) AGAINST ('$all $none $any' IN BOOLEAN MODE) AND lesson.verified= 'yes' $limit" ;
echo "<b>Query passed in:</b>".$query."<br/><br/>";
$artm1 = MySQL_query($query);
if(MySQL_num_rows($artm1) > 0) {
echo "<b>Lesson Plans Matches</b><br>";
echo "<table>";
echo "<table border='1'>";
echo "<tr><td>Lesson ID </td><td>Subject </td><td>Learning area</td> <td>Topic</td> <td>Time period</td><td>Ability</td></tr>";
while($artm2 = MySQL_fetch_array($artm1)) {
echo "<td><a href='customise1.php?lessonID= {$artm2['lessonID']}; '> {$artm2['lessonID']}</a></td>";
//echo "<td>{$artm2['lessonID']}</td>";
echo "<td>{$artm2['subject']}</td>";
echo "<td>{$artm2['learningArea']}</td>";
echo "<td>{$artm2['topic']}</td>";
echo "<td>{$artm2['minutes']}</td>";
echo "<td>{$artm2['ability']}</td></tr>";
}
echo "</table>";
}
else {
echo "No Results were found in this category.<br>";
}
if ($pageno == 1) {
echo " FIRST PREV ";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> ";
$prevpage = $pageno-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> ";
}
//Next we inform the user of his current position in the sequence of available pages.
echo " ( Page $pageno of $lastpage ) ";
//This code will provide the links for any following pages.
if ($pageno == $lastpage) {
echo " NEXT LAST ";
} else {
$nextpage = $pageno+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> ";
echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> ";
} // if
}
echo "<br>";
?>
Okay, I've amended the code above for you to echo values out.
Run it and check the values echoed out for the POST/GET vars and the two queries for the first page and the second page.
Copy the queries to a text file somewhere and run them in phpMyAdmin or MySQL command line over your databse. Make sure that those queries give you data because right now it would seem likely that you'll get nothing out of the first or second (or maybe both) query you run on page 2 of your data and hopefully you can see why.