prethum 0 Newbie Poster

hi i am working on pagination too i have a problem i am sure u can fix it:
i have to list box city and type,
city =list of cities and type=hotel,bars ...
when the user select from the lsit box and press search i get the out put from the mysql
my problem is i see the reult but when i click on page 2,3,4.... or next page to see rest of the result i dont see any thing the serach result returs nothing

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registration Form</title>
<style type="text/css">
<!--
body,td,th {
font-size: 16px;
}
.style1 {font-size: 16px}
body {
background-color: #000000;
}
-->
</style><head>
<link rel="stylesheet" type="text/css" href= "Css/gbt.css" />
<link rel="stylesheet" type="text/css" href= "Css/layout.css" />
<link rel="stylesheet" type="text/css" href= "Css/sugg.css"/>
<script language="JavaScript" type="text/javascript" src="JS/ddtabmenu.js"></script>
<script type="text/javascript" src="JS/jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
function lookup(inputString) {
if(inputString.length == 0) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("autocomplete.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup

function fill(thisValue) {
$('#inputString').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
</script>
</head>
<body link="blue" alink="blue" vlink="blue" >
<div id="container" style="position:relative">
<div id="container">
<div id="header">
<table width="946" height="83" border="0">
<tr>
<td width="202" bgcolor="#FFFFFF"><?PHP include "./Ads.php"?></td>
<td width="466" bordercolor="#FFFFFF" bgcolor="#FFFFFF">&nbsp;</td>
<td width="213" bordercolor="#FFFFFF" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
</table>
<table width="950" border="0">
<tr>
<td width="200" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><img src="img/hotel.jpg" width="200" height="121" /></td>
<td width="200" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><img src="img/restaurant2.jpg" width="200" height="121" /></td>
<td width="200" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><img src="img/vandrarhem.jpg" width="200" height="121" /></td>
<td width="200" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><img src="img/spa.jpg" width="200" height="121" /></td>
</tr>
<tr>
<td colspan="4" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><div align="center">
<p><img src="img/log.jpg" width="482" height="121" /></p>
</div></td>
</tr>
<tr>
<td colspan="4" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><div align="right"><a href="#"><img src="img/Sweden.png"/></a> <a href="chg.php"><img src="img/United Kingdom(Great Britain).png" /></a></div></td>
</tr>
</table>
<div id="glowingtabs">
<ul>
<li><a href="home.php" title="Home" target="_self" ><span>Home</span></a></li>
<li><a href="register.php" title="Upoad Your Ads" target="_self" ><span>Upload Ads</span></a></li>
<li><a href="login.php" title="Login" target="_self" ><span>Login</span></a></li>
<li><a href="register.php" title="Register" target="_self" ><span>Register</span></a></li>
<li><a href="register.php" title="Register" target="_self" ><span>Upload Ads</span></a></li>
</ul>
</div>
<div id="leftBar">
</div>
<div id="content" style="height:500px;width:752px" name ="tar">
<form action="searchdb.php" method="post" name="form1" target="_self" id="form1">
<table width="752" border="0">
<tr>
<td width="350"> <label for="companytype">
<div align="right">Company Type</div>
</label> </td>
<td width="392"><div align="left">
<select name="companytype" id="companytype">
<option>Hotell</option>
<option>Restaurang</option>
<option>Vandrarhen</option>
<option>Pubar</option>
<option>Diskotek</option>
<option>Caf&eacute;er</option>
<option>Spa</option>
<option>Konferens</option>
</select>
</div></td>
</tr>
<tr>
<td>
<label for="kommun">
<div align="right">kommun</div>
</label> </td>
<td><div align="left">
<input type="text" name="kommun" size="30" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
<label for="Search"></label>
<input type="submit" name="Search" id="Search" value="Search" />
</div>
<div class="suggestionsBox" id="suggestions" style="display: none;">
<img src="img/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
<div class="suggestionList" id="autoSuggestionsList"></div>
</div> </td>
</tr>
</table>
</form>
<p>
<?



// connect to the database and query it to show the titles of all the threads,
// and the date when the thread was last posted
$kommun=$_POST['kommun'];
$companytype=$_POST['companytype'];
if(!$kommun)
{
echo "<font color =red>No selection was made</font>";
exit;
}

$rowsPerPage =20;

// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT companytype,companyname,address,telephone FROM addreg where kommun like '$kommun' AND companytype like '$companytype' LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');

// print the random numbers
while($row = mysql_fetch_array($result))
{
echo "Companytype : " .$row['companytype'] . '<br>';
echo "Companyname : " .$row['companyname'] . '<br>';
echo "Address : " .$row['address'] . '<br>';
echo "Telephone : " .$row['telephone'] . '<br>';
echo "<img src='img/divv.jpg' />"."<br>";
}
echo '<br>';

// how many rows we have in database
$query = "SELECT COUNT(companyname) AS numrows FROM addreg where kommun like'$kommun' AND companytype like '$companytype'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];

// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);

// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"$self?page=$page\">$page</a> ";
}
}

// creating previous and next link
// plus the link to go straight to
// the first and last page

if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";

$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = '&nbsp;'; // we're on page one, don't print previous link
$first = '&nbsp;'; // nor the first page link
}

if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";

$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = '&nbsp;'; // we're on the last page, don't print next link
$last = '&nbsp;'; // nor the last page link
}

// print the navigation link
echo $first . $prev . $nav . $next . $last;

// and close the database connection
include '../library/closedb.php';
?>
</p>
</div>
<div id="footer">
footer
</div>
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.