i really appreciate your help but still confused.
The code that i have got allready works expect for when the user clicks on next button. My code is made up in 3 parts. Like i said i cant make next,back links to work. All the rest works fine. I know part 3 of the code is wrong as within the next links there is $query variable which doesnt exist in my code, but looking from code what can i put there?. Also do anyone of my select statement needed editing?
Ive been trying to solve this for a week now, no one can seem to help me. Can you? can you show me where my code needs editing?
<?
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
if (!($limit)){
$limit = 1;} // Default results per-page.
if (!($page)){
$page = 0;} // Default page value.
$numresults = mysql_query("select * from $table_name where job_sector = '$POST[job_sector]' AND region = '$POST[region]'"); // the query.
$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.
$pages = intval($numrows/$limit); // Number of results pages.
// $pages now contains int of pages, unless there is a remainder from division.
if ($numrows % $limit) {
$pages++;} // has remainder so add one page
$current = ($page/$limit) + 1; // Current page number.
if (($pages < 1) || ($pages == 0)) {
$total = 1;} // If $pages is less than one or equal to 0, total pages is 1.
else {
$total = $pages;} // Else total pages is $pages value.
$first = $page + 1; // The first result.
if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) {
$last = $page + $limit;} //If not last results page, last result equals $page plus $limit.
else{
$last = $numrows;} // If last results page, last result equals total number of results.
?>
PART 2
<?
// Now we can display results.
$results = mysql_query("select * from $table_name where job_sector = '$POST[job_sector]' AND region = '$POST[region]' ORDER BY date_posted ASC LIMIT $page, $limit"); // the query.
while ($row = mysql_fetch_array($results))
{
$candidate_id = $row['candidate_id'];
$what_they_do = stripslashes($row['what_they_do']);
$contact_phone = $row['contact_phone'];
$contact_name = $row['contact_name'];
$contact_email = $row['contact_email'];
$date_posted = $row['date_posted'];
$job_title = stripslashes($row['job_title']);
$candidate_description = stripslashes($row['cand_description']);
$short_summary = substr($candidate_description,0,150);
$location = stripslashes($row['location']);
$salary = $row['salary'];
$display_block .= "
<table width=80% border=0 cellspacing=1 cellpadding=0>
<tr bgcolor=#FFEBD7>
<td><a href=candidate_detail.php?candidate_id=$candidate_id>$what_they_do</a><br>$short_summary....<a href=candidate_detail.php?candidate_id=$candidate_id>[More]</a><br><strong>Anticipated Salary:</strong> $salary
</td>
<td width=26% valign=top>$location</td>
</tr>
</table>";
}
if ($numrows == 1){
echo ("<strong>$numrows</strong> candidate matched your search criteria");
}else{
echo ("<strong>$numrows</strong> candidates matched your search criteria");
}
if ($numrows == 0){
echo ("<br><a href='#' onclick='history.back();'>Click here to try a new search</a>");
}
?>
PART 3
<?
$job_sector = $POST['job_sector'];
$region = $POST['region'];
if ($page != 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("<a href=\"$PHP_SELF?query=$query&page=$back_page&limit=$limit\">back</a> \n");}
for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
{
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo("<b>$i</b>\n");} // If current page don't give link, just text.
else{
echo("<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\">$i</a> \n");}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo(" <a href=\"$PHP_SELF?query=$query&page=$next_page&limit=$limit\">next</a>");}
?>