hi, i just wrote a program for my website with a search function. everything works fine but i have a problem with the links to the other result pages. this is the code
<?php
$errors = array();
if ($_POST)
{
$mysql = mysql_connect("localhost", "root", "") or die("couldn't connect to server");
$db = mysql_select_db("jobpage", $mysql) or die("couldn't connect to database");
$keyword = $_REQUEST["keyword"];
$place = $_REQUEST["place"];
$cat_id = $_REQUEST["cat_id"];
$limit = $_REQUEST['limit'];
$page = $_REQUEST['page'];
//set defaults for $limits, $page
if (!($limit) || (is_numeric($limit) == "false") || ($limit < 10) || ($limit > 50)) {
$limit = 10;
}
if (!($page) || (is_numeric($page) == "false") || ($page > $numrows) || ($page <= 0)) {
$page = 1;
}
// set the lower limit where the records would start to display
$start_limit = $page * $limit - $limit;
//build search query first against only the keyword--
$search_db = "SELECT * FROM jobs WHERE job_desc like \"%$keyword%\"";
$search_res = mysql_query($search_db) or die(mysql_error());
$numrows = mysql_num_rows($search_res);
if ($numrows == 0) die ("no matches met your criteria");
// set the total number of pages required
$total_pages = ceil($numrows/$limit);
$search_db = "SELECT * FROM jobs WHERE job_desc like \"%$keyword%\" LIMIT $start_limit, $limit";
$search_res = mysql_query($search_db) or die(mysql_error());
// display what the person searched for
$display .=" <p>You searched for: "" . $keyword . ""</p>";
// begin to show results set
$b = $start_limit + $limit;
$start_limit++;
if ($numrows < $limit){
$display .= "<p>Showing results $start_limit to $numrows of $numrows</p>";
}
else{
$display .= "<p>Showing results $start_limit to $b of $numrows</p>";
}
//first build the top part of the table
$display .= "<TABLE BORDER = '1'>";
$display .= "<TR>";
$display .= "<TH>Job Title</TH><TH>Company</TH><TH>Description</TH><TH>Pay</TH><TH>Location</TH><TH>Date</TH>";
$display .= "</TR>";
// now you can display the results returned
while ($row = mysql_fetch_array($search_res))
{
$title = $row["job_title"];
$desc = $row["job_desc"];
$qua = $row["job_qua"];
$pay = $row["job_pay"];
$req = $row["job_req"];
$date = $row["post_date"];
$comp = $row["comp_name"];
$loc = $row["job_loc"];
$display .= "<TR>";
$display .= "<TD> $title</TD><TD> $comp </TD><TD> $desc </TD><TD> $pay </TD><TD> $loc </TD><TD> $date </TD>";
$display .= "</TR>";
//$count++;// total number of records shown which will be the set_limit, starting point of our limit clause
}
$display .= "</TABLE>";
$previous_page = $page -1;
if ($previous_page >=1){
$display .= "<b><<</b> <a href=".$_SERVER["PHP_SELF"]."?keyword=$keyword&limit=$limit&page=$prev_page><b>Prev.</b></a>";
}
//loop through other pages
for ($a = 1; $a <= $total_pages; $a++){
if ($a == $page){
$display .= "<b>$a | </b>";
}
else {
$display .= "<a href='".$_SERVER["PHP_SELF"]."?keyword=$keyword&limit=$limit&page=$a'> $a </a> |";
}
}
$next_page = $page +1;
if ($next_page <=$total_pages){
$display .= "<a href=".$_SERVER["PHP_SELF"]."?keyword=$keyword&limit=$limit&page=$next_page><b>Next</b></a> > >";
}
}
else {
header("location: sbd.html");
}
?>
note: one lines 82, 92 and 100 where i put the links to the other pages, i also tried: href='job_search.php'?keyword.......
the idea is that when one clicks on the links, a new query would be built so the variables required for the query are passed in the link.
ALSO: does anyone know how i can modify this code to show details when a user click on the results
if anybody knows what's wrong, please help me out
thanks