Hi,
I have been reading through the posts and Have really learned alot, so thanks everyone.
So here is my problem, I have a form which allows the user to pick a price range and a few othere search criteria.( I use GET on this form.) It is sent to the code below, it out puts the first 15 results just fine, but when you click on the next it does not pass the info to the next page . I can't figure out where and how to pass the values that where selected on the original form. If someone could read through my code and find out where the problem is I would really appreciate it.
I was hoping a fresh pair of eyes could help.
Thanks in advance.
<?
/*=========================================*/
/*==Variables used through out the script==*/
/*=========================================*/
$server = "localhost"; // Server Name
$userid = "********"; // Username
$pass = "********"; // Password
$database = "***************"; // Database Name
$dbtable = "******"; // Table Name
$recordLimit= 15; // Limit per page
/*==============================================*/
/*==Font control for the Next/Prev Naviagation==*/
/*==============================================*/
$prevStatus = "Show Previous $recordLimit Results";
$nextStatus = "Show Next $recordLimit Results";
$prevLink = "< Previous|";
$nextLink = "|Next >";
$fontfamily = "tahoma, helvetica";
$fontsize = "13px";
$fontcolor = "#000000";
$inactivecolor = "#666666"; // Color for when there is no link
$fontweight = "700";
$textdecoration = "none";
/*==========================================*/
/*==Window Status of individual page links==*/
/*==========================================*/
function pageStatus($i){
echo " Click to View Page $i";
}
/*========================================*/
/*==Make server and database connections==*/
/*========================================*/
$con = mysql_connect("$server","$userid","$pass")
or die ("Connection Error to Server");
$db = mysql_select_db("$database",$con)
or die("Connection Error to Database");
/*==================================================*/
/*==If thisOffset not set, set to zero==============*/
/*==================================================*/
if (!isset($thisOffset) || $thisOffset < 0) $thisOffset=0;
if ($action==search) $thisOffset = $thisOffset - 1;
/*==================================================*/
/*==This is to count the line index of the results==*/
/*=============if not set, set to zero==============*/
/*==================================================*/
if (!isset($lineIndex) || $lineIndex < 0) $lineIndex=0;
if ($action==search) $lineIndex = $lineIndex - 1;
/*========================================*/
/*==Set Base SQL Statement for the query==*/
/*========================================*/
$sql=("select * from $dbtable WHERE members < '$members' AND software >= '$software'
order by rating asc");
//$sql.=" WHERE category = ''";
/*======================================*/
/*==Query for the total number of rows==*/
/*======================================*/
$getTotalRows = mysql_query($sql, $con);
$totalRowsNum = mysql_num_rows($getTotalRows);
/*==========================================*/
/*==Append the limit and offset to the sql==*/
/*==========================================*/
$sql.="$query Limit $thisOffset,$recordLimit";
/*===================================================*/
/*==Query and fetch array with the limit and offset==*/
/*===================================================*/
$query = mysql_query($sql, $con);
while ($result=mysql_fetch_array($query)){
/*=================================*/
/*==Increment the line index by 1==*/
/*=================================*/
$lineIndex++;
/*============================================*/
/*====== Your results layout goes here =======*/
/*============================================*/
$id=$result ['id'];
$name=$result ["name"];
$url=$result ["url"];
$members=$result ["members"];
$software=$result ["software"];
$description=$result ["description"];
$rating=$result ["rating"];
print ($result % 2) ? "<tr bgcolor=\"#FFFFFF\">" : "<tr bgcolor=\"#d3d3d3\">";
echo "<td align=middle><A HREF=\"$url\" target=\"_blank\">$name</A></td><td
align=middle>$members</td>";
print "<td align=middle>$software</td>";
print "<td align=middle>$description</td>";
print "<td align=middle>$rating</td>";
}
/*===================================================================*/
/*==If the number of returned is less than the limit, show nothing===*/
/*===================================================================*/
if ($totalRowsNum <= $recordLimit) {
// less than recordLimit returned.
} else {
/*==============================================*/
/*==If the current offset is not equal to zero==*/
/*==Show the link. Else (if>0) show just text===*/
/*==============================================*/
if ($thisOffset!=0) { $prevOffset = intval($thisOffset-$recordLimit);
echo "<a style='font-family:$fontfamily; font-size:$fontsize; color:$fontcolor;
font-weight:$fontweight;"
." text-decoration:$textdecoration;' onmouseover=\"window.status='$prevStatus';
return true\""
." onmouseout=\"window.status=''\"
href=\"$PHP_SELF?thisOffset=$prevOffset&lineIndex=$prevOffset\">"
."$prevLink</a> ";
}
else { echo "<span style='font-family:$fontfamily; font-size:$fontsize;
color:$inactivecolor;"
." font-weight:$fontweight; text-decoration:$textdecoration;'>$prevLink</span> ";
}
/*================================================================*/
/*==Divide total rows by record limit to get the number of pages==*/
/*================================================================*/
$totalPages = intval($totalRowsNum/$recordLimit);
/*===========================================================*/
/*==If remainder is left from division increment totalPages==*/
/*===========================================================*/
if ($totalRowsNum%$recordLimit) $totalPages++;
/*===========================================================*/
/*==Using a for() loop, Display links for each page. 1 2 3==*/
/*===========================================================*/
for ($i=1;$i<=$totalPages;$i++) {
/*==================================================================*/
/*==If the page being viewed is the current page, disable the link==*/
/*==================================================================*/
if ((intval($thisOffset/$recordLimit)) == (intval($i-1))) {
echo " <span style='font-family:$fontfamily; font-size:$fontsize;
color:$inactivecolor;"
." font-weight:$fontweight; text-decoration:$textdecoration;'>$i</span> ";
} else {
/*=======================================================*/
/*==If not current page, set nextOffset and display link==*/
/*=======================================================*/
$nextOffset= intval($recordLimit*($i-1));
echo " <a style='font-family:$fontfamily; font-size:$fontsize; color:$fontcolor;"
." font-weight:$fontweight; text-decoration:$textdecoration;'
onmouseover=\"window.status='";
pageStatus($i);
echo "'; return true\" onmouseout=\"window.status=''\""
." href=\"$PHP_SELF?thisOffset=$nextOffset&lineIndex=$nextOffset\">$i</a> ";
}
}
/*==========================================================================*/
/*==If the page is not the last page, set the nextOffset and show the link==*/
/*==============If the page is the last page disable the link===============*/
/*==========================================================================*/
if (!(intval(((intval($thisOffset/$recordLimit))+1))==$totalPages) &&
$totalPages!=1) {
$nextOffset = intval($thisOffset+$recordLimit);
echo " <a style='font-family:$fontfamily; font-size:$fontsize; color:$fontcolor;
font-weight:$fontweight;"
." text-decoration:$textdecoration;' onmouseover=\"window.status='$nextStatus';
return true\""
." onmouseout=\"window.status=''\"
href=\"$PHP_SELF?thisOffset=$nextOffset&lineIndex=$nextOffset\">$nextLink</a><p>\n";
}
else echo " "
."<span style='font-family:$fontfamily; font-size:$fontsize; color:$inactivecolor;"
." font-weight:$fontweight; text-decoration:$textdecoration;'>$nextLink</span><p>";
}
mysql_close($con);
//End
?>
Thanks for the help in advance