Depending on what search criteria you choose from the case method, determines the number of rows and paginates the results accordingly. However if I select a specific criteria, i.e. by date it lists the results with the proper amount of paginated result numbers, but as soon as I click on a paginted result link (2, 3, etc.) it looses the $_POST value of the select menu items and displays random rows, ..however I want to continue displaying records in paginated links that corelate to the query in the case method in paginated links 2,3,4 etc. (however many results the query returns)......
I am able to return the $POST value upon a select menu choice, but how can I return the $POST value upon a click of a pagination link and have it display records that match a criteria seemlessly in paginated results?.........
if (empty($offset)) {
$offset=0;
}
include("manage/modify.php");
$query = "Select * FROM $table WHERE username = '".$_SESSION['username']."'";
switch($_POST['sort']) {
case 1:
$query.=" ORDER by date DESC";
break;
case 2:
$query.=" AND awareness = 'Low' ORDER by awareness";
break;
case 3:
$query.=" AND awareness = 'Medium' ORDER by awareness";
break;
case 4:
$query.=" AND awareness = 'High' ORDER by awareness";
break;
case 5:
$query.=" AND dreamstatus = 'Past' ORDER by dreamstatus";
break;
case 6:
$query.=" AND dreamstatus = 'Recent' ORDER by dreamstatus";
break;
}
$limit = 11;
$query1 = $query." limit $offset, $limit";
$result = mysql_query($query,$db); //total results
$total_rows = mysql_num_rows($result);
mysql_free_result($result);
$result = mysql_query($query1,$db); //actual results
$numrows = mysql_result($result, 0, 0);
print "<table align=\"center\" width=\"95%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\" class=\"table_border\">\n";
print "<tr><td colspan=\"6\">";
print "<form name=\"form2\" method=\"post\" action=\"home.php?page=manage&action=entries\"><select name=\"sort\" style=\"font-size: 11px; font-weight: bold; color: 000000;\" onchange=\"document.forms['form2'].submit()\">";
if($_POST['sort'] != 1 or 2 or 3 or 4 or 5 or 6) {
echo "<option selected value=\"1\">Sort by Category</option>";
} else {
echo "<option>Sort by Category</option>";
}
if($_POST['sort'] == 1) {
echo "<option selected value=\"1\">Sort by Date</option>";
} else {
echo "<option value=\"1\">Sort by Date</option>";
}
if($_POST['sort'] == 2) {
echo "<option selected value=\"2\">Sort by Awareness(Low)</option>";
} else {
echo "<option value=\"2\">Sort by Awareness(Low)</option>";
}
if($_POST['sort'] == 3) {
echo "<option selected value=\"3\">Sort by Awareness(Medium)</option>";
} else {
echo "<option value=\"3\">Sort by Awareness(Medium)</option>";
}
if($_POST['sort'] == 4) {
echo "<option selected value=\"4\">Sort by Awareness(High)</option>";
} else {
echo "<option value=\"4\">Sort by Awareness(High)</option>";
}
if($_POST['sort'] == 5) {
echo "<option selected value=\"5\">Sort by Past Journals</option>";
} else {
echo "<option value=\"5\">Sort by Past Journals</option>";
}
if($_POST['sort'] == 6) {
echo "<option selected value=\"6\">Sort by Recent Journals</option>";
} else {
echo "<option value=\"6\">Sort by Recent Journals</option>";
}
print "</select></form>";
if (mysql_num_rows ($result) == 0) {
print "<tr class=\"cells\"><td colspan=\"6\"><font color=red>No entries found. Please select another search criteria.</font></td></tr>";
} else {
$p .= "<tr class=\"header_cell\">";
$p .= "<td>Date</td><td>Title</td><td>Past or Recent</td><td>Awareness</td><td>Modify</td><td>Delete</td></tr>\n";
echo $p;
while(list($id,$date,$username,$title,$dreamstatus,$entry,$awareness,$pagination) = mysql_fetch_row($result)){
$d = explode("-",$date);
$titletrimmed = substr($title, 0, 30);
$thedate = "$d[2]/$d[1]/$d[0]";
$print = "\n<tr class=\"cells\">\n";
$print .= "<td><li>$date</td><td><b><a href=\"home.php?page=manage&action=modify&entry=$id\">$titletrimmed...</a></b></td>\n";
$print .= "<td>$dreamstatus</td>";
$print .= "<td>$awareness</td>";
$print .= "<td align=\"center\"><a href=\"home.php?page=manage&action=modify&entry=$id\">";
$print .= "Modify</a></td>\n";
$print .= "<td align=\"center\"><a href=\"home.php?page=manage&action=remove&entry=$id\">";
$print .= "Delete</a></td>\n";
$print .= "</tr>\n";
echo $print;
}
}
echo"</table><br></center>";
// NEXT - PREVIOUS LINKS \\
if (mysql_num_rows ($result) <= 10) {
echo "<center>";
} else {
echo "<center>Results: ";
}
$pages=intval($total_rows/$limit);
if ($total_rows%$limit!=0) {
$pages++;
}
if($pages > $limit){
echo"";
}
if ($offset != 0) {
$prevoffset=$offset-$limit;
echo "<a class=i href=\"$PHP_SELF?page=manage&action=entries&offset=$prevoffset\"><<</a> \n";
}
if ( $pages != 1 ) {
for ($l=1;$l<=$pages;$l++) {
$newoffset=$limit*($l-1);
if ( ((($offset)/$limit)==($l-1)) ) {
echo "<font class=i>$l</font> | \n";
} else {
echo "<a class=i href=\"$PHP_SELF?page=manage&action=entries&offset=$newoffset\">$l</a> | \n";
}
}
}
if (!((($offset)/$limit)+1==$pages) && $pages!=1) {
$newoffset=$offset+$limit;
echo "<a class=i href=\"$PHP_SELF?page=manage&action=entries&offset=$newoffset\">>></a><p>\n";
}
}