if (!$state && !$country) {
header("Location:member_directory.php");
exit;
}
echo $_GET['state']."<BR>";
echo $_get['country']."<br>";
$pagelimit = "3";
// run query (change yourtable to the name of your table)
$strSQL = mysql_query("SELECT * FROM tblinfo");
// count number of matches
$totalrows = mysql_num_rows($strSQL);
// determine how many pages there will be by using ceil() and dividing total rows by pagelimit
$pagenums = ceil ($totalrows/$pagelimit);
// if no value for page, page = 1
if ($page==''){
$page='1';
}
// create a start value
$start = ($page-1) * $pagelimit;
// blank matches found
//echo "<b>" . $totalrows . " matches found</b><br>\n";
// Showing Results 1 to 1 (or if you're page limit were 5) 1 to 5, etc.
$starting_no = $start + 1;
if ($totalrows - $start < $pagelimit) {
$end_count = $totalrows;
} elseif ($totalrows - $start >= $pagelimit) {
$end_count = $start + $pagelimit;
}
echo "Results $starting_no to $end_count shown.<br>\n";
// create dynamic next, previous, and page links
/* lets say you're set to show 5 results per page and your script comes out with 7 results.
this will allow your script to say next2 if you're on the first page and previous5 if you're on the second page. */
if ($totalrows - $end_count > $pagelimit) {
$var2 = $pagelimit;
} elseif ($totalrows - $end_count <= $pagelimit) {
$var2 = $totalrows - $end_count;
}
$space = " ";
/* output your data wherever you'd like.
//$strSQL = mysql_query("SELECT * FROM $table LIMIT $start,$pagelimit");
// LIMIT 0,10 will start at 0 and display 10 results
// LIMIT 10,5 will start at 10 and display 5 results
/* now you can do whatever you'd like with this query. it will only output one page at a time. change the $pagelimit variable to whatever to output more than 1 result per page. */
if (!$state) {
$fanclublistquery = mysql_query("SELECT * FROM tblinfo where infCountry='$country' order by infFanclubNo limit $start, $pagelimit");
}else{
$fanclublistquery = mysql_query("SELECT * FROM tblinfo where infState='$state' order by infFanclubNo limit $start, $pagelimit");
}
while ($fanclublist = mysql_fetch_array ($fanclublistquery)) {
$fanclubno = $fanclublist["infFanclubNo"];
$name = $fanclublist["infName"];
$city = $fanclublist["infCity"];
$disp_state = $fanclublist["infState"];
$postal = $fanclublist["infPostal"];
$disp_country = $fanclublist["infCountry"];
$email = $fanclublist["infEmail"];
$homepage = $fanclublist["infHomepage"];
$aolim = $fanclublist["infAOLIM"];
$icq = $fanclublist["infICQ"];
$image = $fanclublist["infImage"];
$interests = $fanclublist["infInterests"];
$dob = $fanclublist["infDOB"];
$comments = $fanclublist["infComments"];
$member_list .= sprintf ("<TR valign=\"top\">\r\n");
$member_list .= sprintf ("<TD><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s</font></TD>\r\n", $name);
$member_list .= sprintf ("<TD><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s</font></TD>\r\n", $fanclubno);
$member_list .= sprintf ("<TD><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s</font></TD>\r\n", $city);
$member_list .= sprintf ("<TD><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s</font></TD>\r\n", $disp_state);
$member_list .= sprintf ("<TD><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s</font></TD>\r\n", $disp_country);
$member_list .= sprintf ("<TD><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><A HREF=\"profile.php?fanclubno=%s\">Profile</A></font></TD>\r\n", $fanclubno);
$member_list .= sprintf ("</TR>\r\n");
}
?>
then there's some html(not important)
<?
// previous link (make sure to change yourpage.php to the name of your page)
if ($page>1) {
if (!$state) {
echo "« <a href='by_location.php?country=".$country."&&page=".($page-1)."' class=main>Previous" . $space . $pagelimit . "</a>" . $space . $space . "";
} else {
echo "« <a href='by_location.php?state=".$state."&&page=".($page-1)."' class=main>Previous" . $space . $pagelimit . "</a>" . $space . $space . "";
}
// dynamic page number links (make sure to change yourpage.php to the name of your page)
for ($i=1; $i<=$pagenums; $i++) {
if ($i!=$page) {
if (!$state) {
echo " <a href='by_location.php?country=".$country."&&page=$i' class=main>$i</a>";
} elseif (!$country) {
echo " <a href='by_location.php?state=".$state."&&page=$i' class=main>$i</a>";
}
else {
echo " <b class='red'>$i</b>";
}
}
// next link (make sure to change yourpage.php to the name of your page)
if ($page<$pagenums) {
if(!$country) {
echo "" . $space . $space . $space . $space . " <a href='by_location.php?state=".$state."&&page=".($page+1)."' class=main>Next " . $var2 . "</a> »";
}
elseif(!$state) {
echo "" . $space . $space . $space . $space . " <a href='by_location.php?country=".$country."&&page=".($page+1)."' class=main>Next " . $var2 . "</a> »";
}
}
?>
I had this working fine and then I added the if statements to check if there's a $state variable or a $country variable. I have no idea where line 331 is.
By the way I used some code from another thread that someone offered to help create limits to rows returned per page and links to the rest of the result set.