I'm working on a site where males can search for females and vice versa.
The results are shown on different pages from 1 to 10 .... next
Problem that i have is that the first 2 pages are correct and by clicking page 3 it mixes all genders instead of only displaying females or males.
Try for yourself at http://www.mon-amour.be and click zoeken=search
My searchquery is here!
please advice me on this one?
Thanks
Marc
<?// Creating search query:
$query = "SELECT count(p.id) as count1 FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where");
$rec_count = f(q($query));
$rec_count = $rec_count["count1"];
$page_count = 0;
if($records_per_page >= $rec_count)
{
$search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where");
}
else
{
$page_count = $rec_count / $records_per_page;
$page_count = ceil($page_count);
settype($page_num, "integer");
if(!$page_num)$page_num++;
if($page_num > $page_count)
{
$page_num = $page_count;
}
$from = ($page_num - 1) * $records_per_page;
$search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." ORDER BY p.lastlogin DESC limit $from, $records_per_page";
}
}
$profiles = q($search_query);
//echo $search_query;
include "templates/search_results.ihtml";
}
else
{
foreach($_SESSION as $k => $v)
{
if(substr($k, 0, 7) != "search_")
continue;
session_unregister($_SESSION[$k]);
}
session_unset();
session_destroy();
include "templates/easy_search.ihtml";
}
?>
The output code is in another file and looks like this.
<?
$npages = $page_count;
$p = $page_num;
if ($npages > 1)
{
$params = "";
foreach($_GET as $k => $v)
{
if($k == "page_num")
{
continue;
}
$params .= "$k=$v&";
}
echo "Totaal gevonden: ";
if ($p != 1)
{
echo '</a><a href="index.php?'.$params.'page_num='.($p-1).'"><b>Vorige</b></a> ';
}
$lend = floor($p/10)*10;
if ($lend < 1) { $lend = 1;}
if ($npages > 19)
{
$hend = $lend + 19;
if ($hend > $npages) { $hend = $npages;}
}
else { $hend = $npages;}
for ($i = $lend; $i <= $hend; $i++)
{
if ($i == $p)
{
echo $i." ";
}
else
{
echo '<a href="index.php?'.$params.'page_num='.$i.'">'.$i.'</a> ';
}
}
if ($p != $npages)
{
echo ' <a href="index.php?'.$params.'page_num='.($p+1).'"><b>Volgende</b></a> ';
}
}
?> </td>
</tr>
<tr>
<td height="20" bgcolor="#E50026"> </td>
</tr>
<tr>
<td>
<?php
/*
if($page_count > 0)
{
for($j = 0; $j < $page_count; $j++)
{
?>
[<a href="index.php?<?php echo $params;?>page_num=<?php echo ($j + 1)?>">Pagina<?php echo ($j + 1)?></a>]
<?php
}
}
*/
?>
<?
if(e($profiles))
{
?>