In this db and query are working and the firs page but after the 2nd page the variables are not passing can any one help me on this

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php 
  
  include("../init/db.php");
  
  $yearfom = $_POST["yearFrom"];
	$yearTo = $_POST["yearTo"];
	
	$Year ="SELECT";
	
	if($yearfom!="SELECT"){
		$Year ="";
		}
	
		$content = array("make"=>$_POST["make"],
					 "model"=>$_POST["model"],
					 "year"=>"$Year");


   
    $validValues=array();

	foreach ($content as $key=>$value)
	{
		if($value != "SELECT")
		  {
			 $validValues[$key]=$value;	
							
		  }
		  
	}
	
	$query ="select * from cars where ";
	foreach($validValues as $key=>$value)
	{

		$query1 = $query.$key."='".$value."' AND ";
		$qu1=true;
		if($key == "year"){
			$query1 = substr($query1,0,-8);
			$query2 = $query1." BETWEEN '".$yearfom."' AND ' ".$yearTo."' ";
			$qu1=false;
			$qu2=true;
			
			}
			
				
	}
	
	if($qu1==true){
	$query = substr($query1,0,-4);
	echo $sql = $query;
	
	}elseif($qu2==true){
		
		$query = $query2;
		echo $sql = $query;
		}		
  
  
// how many rows to show per page
$rowsPerPage = 2;

// 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;
  
 
 
 
 
// $sql= "select * from cars where year BETWEEN '2007' AND ' 2009' ";
  $result=mysql_query($sql);
   $row=mysql_num_rows($result);
     
  while($info=mysql_fetch_array($result)){


    
	 $make = $info['make'];
	  $model = $info['model'];
	  $price = $info['price'];
	  $features = $info['features'];
	  $year= $info['year'];
	  
	 $pic1=$info['pic1'];
	 $pic2=$info['pic2'];
	  $pic3=$info['pic3'];
				   
		   
	  $id = $info['id'];
	  $desc=str_replace ("<li>", "   ", $features);
	  
	   $ftt = substr($desc,0,120)."................."; 
	    $abc="'viewad.php?id=$id'";


echo	'<div id="adcontent"><a  onclick="javascript:popUp('.$abc.')"">
	<div id="cars">
  			<div style="background-color:#0091DE; padding:5px; font-weight: bold; color:#FFF;">
   		 '.$make.' - '.$model.' -  '.$year.'
     	    </div>
 			 <div style="padding:10px; font-size: 30px;">
      			<img src="'.$pic1.'" width="20%" height="20%" style="margin:5px;"/>    
   		 		<img src="'.$pic2.'" width="20%" height="20%" style="margin:5px;" />
    			<img src="'.$pic3.'" width="20%" height="20%"style="margin:5px;"/> $ '.$price.' 
             </div>  
  				<div style="padding: 15px;">    
    			<P style="font-size: 12px; font-weight: normal;"> 
     			 '.	$ftt.'      
     				 </P>    
 				 </div>
  				<img src="image/images/carbot.gif" width="500" height="10" />
 			 </div></a>
  
	</div>';
	  
	  }
	


// how many rows we have in database
$foreditqu= substr($sql,19,-1);
echo $foreditqu;

$query   = "SELECT COUNT(id) AS numrows FROM cars ".$foreditqu;
echo $query;
$result  = mysql_query($query) or die('Error, query failed');
$row     = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<br />".$numrows = $row['numrows'];

echo "<br />";
// how many pages we have when using paging?
echo $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;


  ?>
<form id="form1" name="F2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <div style="background-color:#84C8FD; text-align: center;">
    <h2>Find a Car</h2>
  </div>
  <table width="224" border="0">
    <tr>
      <td width="42">Make</td>
      <td colspan="2"><label for="make"></label>
        <select name="make" id="master">
          <option value="SILECT">Select</option>
          <option value="AC">AC </option>
          <option value="ALFA ROMEO ">ALFA ROMEO </option>
          <option value="ASIA ">ASIA </option>
          <option value="AMAROO ">AMAROO </option>
          <option value="ASTON MARTIN ">ASTON MARTIN </option>
          <option value="AUDI ">AUDI </option>
          <option value="AUSTIN ">AUSTIN </option>
          <option value="AUSTIN HEALEY ">AUSTIN HEALEY </option>
          <option value="BEDFORD ">BEDFORD </option>
          <option value="BENTLEY ">BENTLEY </option>
          <option value="BERTONE ">BERTONE </option>
          <option value="BMW ">BMW </option>
        </select></td>
    </tr>
    <tr>
      <td>Model</td>
      <td colspan="2"><label for="model"></label>
        <select name="model" id="slave">
          <option value="SELECT">Select</option>
        </select></td>
    </tr>
    <tr>
      <td>Year</td>
      <td width="80"><label for="yearFrom"></label>
        <select name="yearFrom" id="yearFrom">
          <option value="SELECT">From</option>
          <option value="2008">2008</option>
          <option value="2009">2009</option>
        </select></td>
      <td width="80"><select name="yearTo" id="yearTo">
        <option value="SELECT">To</option>
        <option value="2008">2008</option>
        <option value="2009">2009</option>
      </select></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input name="input" type="submit" value="Search" />
        &nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>

Recommended Answers

All 6 Replies

send your db.php and database structure...........

try this..........!!

---------------------------------------------------------------------------------

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php 
if(isset($_POST['input'])) {
  include("../init/db.php");
  
  $yearfom = $_POST["yearFrom"];
	$yearTo = $_POST["yearTo"];
	
	$Year ="SELECT";
	
	if($yearfom!="SELECT"){
		$Year ="";
		}
	
		$content = array("make"=>$_POST["make"],
					 "model"=>$_POST["model"],
					 "year"=>"$Year");


   
    $validValues=array();

	foreach ($content as $key=>$value)
	{
		if($value != "SELECT")
		  {
			 $validValues[$key]=$value;	
							
		  }
		  
	}
	
	$query ="select * from cars where ";
	foreach($validValues as $key=>$value)
	{

		$query1 = $query.$key."='".$value."' AND ";
		$qu1=true;
		if($key == "year"){
			$query1 = substr($query1,0,-8);
			$query2 = $query1." BETWEEN '".$yearfom."' AND ' ".$yearTo."' ";
			$qu1=false;
			$qu2=true;
			
			}
			
				
	}
	
	if($qu1==true){
	$query = substr($query1,0,-4);
	echo $sql = $query;
	
	}elseif($qu2==true){
		
		$query = $query2;
		echo $sql = $query;
		}		
  
  
// how many rows to show per page
$rowsPerPage = 2;

// 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;
  
 
 
 
 
// $sql= "select * from cars where year BETWEEN '2007' AND ' 2009' ";
  $result=mysql_query($sql);
   $row=mysql_num_rows($result);
     
  while($info=mysql_fetch_array($result)){


    
	 $make = $info['make'];
	  $model = $info['model'];
	  $price = $info['price'];
	  $features = $info['features'];
	  $year= $info['year'];
	  
	 $pic1=$info['pic1'];
	 $pic2=$info['pic2'];
	  $pic3=$info['pic3'];
				   
		   
	  $id = $info['id'];
	  $desc=str_replace ("<li>", "   ", $features);
	  
	   $ftt = substr($desc,0,120)."................."; 
	    $abc="'viewad.php?id=$id'";


echo	'<div id="adcontent"><a  onclick="javascript<b></b>:popUp('.$abc.')"">
	<div id="cars">
  			<div style="background-color:#0091DE; padding:5px; font-weight: bold; color:#FFF;">
   		 '.$make.' - '.$model.' -  '.$year.'
     	    </div>
 			 <div style="padding:10px; font-size: 30px;">
      			<img src="'.$pic1.'" width="20%" height="20%" style="margin:5px;"/>    
   		 		<img src="'.$pic2.'" width="20%" height="20%" style="margin:5px;" />
    			<img src="'.$pic3.'" width="20%" height="20%"style="margin:5px;"/> $ '.$price.' 
             </div>  
  				<div style="padding: 15px;">    
    			<P style="font-size: 12px; font-weight: normal;"> 
     			 '.	$ftt.'      
     				 </P>    
 				 </div>
  				<img src="image/images/carbot.gif" width="500" height="10" />
 			 </div></a>
  
	</div>';
	  
	  }
	


// how many rows we have in database
$foreditqu= substr($sql,19,-1);
echo $foreditqu;

$query   = "SELECT COUNT(id) AS numrows FROM cars ".$foreditqu;
echo $query;
$result  = mysql_query($query) or die('Error, query failed');
$row     = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<br />".$numrows = $row['numrows'];

echo "<br />";
// how many pages we have when using paging?
echo $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;

}
  ?>
<form id="form1" name="F2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <div style="background-color:#84C8FD; text-align: center;">
    <h2>Find a Car</h2>
  </div>
  <table width="224" border="0">
    <tr>
      <td width="42">Make</td>
      <td colspan="2"><label for="make"></label>
        <select name="make" id="master">
          <option value="SILECT">Select</option>
          <option value="AC">AC </option>
          <option value="ALFA ROMEO ">ALFA ROMEO </option>
          <option value="ASIA ">ASIA </option>
          <option value="AMAROO ">AMAROO </option>
          <option value="ASTON MARTIN ">ASTON MARTIN </option>
          <option value="AUDI ">AUDI </option>
          <option value="AUSTIN ">AUSTIN </option>
          <option value="AUSTIN HEALEY ">AUSTIN HEALEY </option>
          <option value="BEDFORD ">BEDFORD </option>
          <option value="BENTLEY ">BENTLEY </option>
          <option value="BERTONE ">BERTONE </option>
          <option value="BMW ">BMW </option>
        </select></td>
    </tr>
    <tr>
      <td>Model</td>
      <td colspan="2"><label for="model"></label>
        <select name="model" id="slave">
          <option value="SELECT">Select</option>
        </select></td>
    </tr>
    <tr>
      <td>Year</td>
      <td width="80"><label for="yearFrom"></label>
        <select name="yearFrom" id="yearFrom">
          <option value="SELECT">From</option>
          <option value="2008">2008</option>
          <option value="2009">2009</option>
        </select></td>
      <td width="80"><select name="yearTo" id="yearTo">
        <option value="SELECT">To</option>
        <option value="2008">2008</option>
        <option value="2009">2009</option>
      </select></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input name="input" type="submit" value="Search" />
        &nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>

db.php

<?php
$MYSQL_SERVER='localhost'; //sessions not need for this one
	$MYSQL_USER='root';
	$MYSQL_DB='bcar';
	
		mysql_connect($MYSQL_SERVER,$MYSQL_USER) || die("Error connecting the database");
	mysql_select_db($MYSQL_DB) || die("Error Selecting the database");
	?>

Table

CREATE TABLE IF NOT EXISTS `cars` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `make` varchar(50) NOT NULL,
  `model` varchar(50) NOT NULL,
  `trans` varchar(50) NOT NULL,
  `fuel` varchar(50) NOT NULL,
  `year` int(11) NOT NULL,
  `km` int(11) NOT NULL,
  `vin` int(11) NOT NULL,
  `regdetails` varchar(50) NOT NULL,
  `state` varchar(50) NOT NULL,
  `price` varchar(100) NOT NULL,
  `features` varchar(1000) NOT NULL,
  `pic1` varchar(5000) NOT NULL,
  `pic2` varchar(5000) NOT NULL,
  `pic3` varchar(5000) NOT NULL,
  `pic4` varchar(5000) NOT NULL,
  `pic5` varchar(5000) NOT NULL,
  `pic6` varchar(5000) NOT NULL,
  `uname` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uname` (`uname`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;

--
-- Dumping data for table `cars`
--

INSERT INTO `cars` (`id`, `make`, `model`, `trans`, `fuel`, `year`, `km`, `vin`, `regdetails`, `state`, `price`, `features`, `pic1`, `pic2`, `pic3`, `pic4`, `pic5`, `pic6`, `uname`) VALUES
(14, 'ALFA ROMEO ', 'ALFA', 'Automatic', 'Gasoline/Petrol', 2009, 0, 0, 'Unregisted', 'Northern Territory', 'ASK', '<li>Anti-Lock Brakes(ABS)</li><li>Driver Airbag</li><li>Passenger Airbag</li><li>Side Airbag</li><li>Alarm</li><li>A/C:front</li><li>Cruise Control</li><li>Navigation System</li><li>Power Steering</li><li>Remote Keyless Entry</li><li>Tilt Wheel</li><li>Digital Meter</li><li>Child Seat</li><li>Leather Seats</li><li>Power Seats</li><li>Bucket Seat</li><li>Power Windows</li><li>Rear Window Wiper</li><li>Tinted Glass</li><li>AM/FM Radio</li><li>AM/FM Stereo</li><li>CD Changer</li><li>CD Player</li><li>Premium Sound</li><li>Satellite Radio</li><li>DVD</li><li>TV</li><li>Alloy Wheels</li><li>Power Door Locks</li><li>Power Mirrors</li><li>Sunroof</li><li>Third Row Seats</li><li>Power Slide Door</li><li>Custom wheels</li><li>Fully loaded</li><li>Maintenance records available</li><li>New paint</li><li>New tires</li><li>No accidents</li><li>One owner</li><li>Performance tires</li><li>Upgraded sound system</li><li>Turbo</li>', './adpics/AlfaRomeoC8.jpg', './adpics/Alfa-Romeo-8c-Competizione.jpg', './adpics/alfa-romeo-8c.jpg', './adpics/alfa-8c.jpg', './adpics/alfa8c.jpg', './adpics/2003_Alfa_Romeo_8C_Competizione_Concept.jpg', 'nirman'),
(11, 'BMW ', 'M3', 'Automatic', 'Diesel', 2007, 123, 0, 'Unregisted', 'Western Australia', 'ASK', '<li>Anti-Lock Brakes(ABS)</li><li>Driver Airbag</li><li>Passenger Airbag</li><li>Side Airbag</li><li>Alarm</li><li>Power Door Locks</li><li>Power Mirrors</li>', './adpics/2009_Camaro_1.jpg', './adpics/0007500089184_500X500.jpg', './adpics/0088732421005_AV_500X500.jpg', './adpics/AustraliaMap.png', './adpics/Iloverock.gif', './adpics/YeahIloverock.jpg', 'ruwanaru'),
(12, 'BMW ', 'M3', 'Automatic', 'Diesel', 2009, 123, 0, 'Unregisted', 'Western Australia', 'ASK', '<li>Anti-Lock Brakes(ABS)</li><li>Driver Airbag</li><li>Passenger Airbag</li><li>Side Airbag</li><li>Alarm</li><li>Power Door Locks</li><li>Power Mirrors</li>', './adpics/2009_Camaro_1.jpg', './adpics/0007500089184_500X500.jpg', './adpics/0088732421005_AV_500X500.jpg', './adpics/AustraliaMap.png', './adpics/Iloverock.gif', './adpics/YeahIloverock.jpg', 'ruwanaru'),
(13, 'AUDI ', 'R8', 'Automanual', 'Gasoline/Petrol', 2008, 123, 0, 'Unregisted', 'Northern Territory', 'ASK', '<li>Anti-Lock Brakes(ABS)</li><li>Driver Airbag</li><li>Passenger Airbag</li><li>Side Airbag</li><li>Alarm</li><li>A/C:front</li><li>Cruise Control</li><li>Navigation System</li><li>Power Windows</li><li>DVD</li>', './adpics/2009_Camaro_1.jpg', './adpics/0007500089184_500X500.jpg', './adpics/2009_Camaro_1.jpg', './adpics/AustraliaMap.png', './adpics/2009_Camaro_1.jpg', '../adpics/2009_Camaro_1.jpg', 'nirman'),
(15, 'ALFA ROMEO ', 'ALFA', 'Automatic', 'Gasoline/Petrol', 2009, 0, 0, 'Unregisted', 'Northern Territory', 'ASK', '<li>Anti-Lock Brakes(ABS)</li><li>Driver Airbag</li><li>Passenger Airbag</li><li>Side Airbag</li><li>Alarm</li><li>A/C:front</li><li>Cruise Control</li><li>Navigation System</li><li>Power Steering</li><li>Remote Keyless Entry</li><li>Tilt Wheel</li><li>Digital Meter</li><li>Child Seat</li><li>Leather Seats</li><li>Power Seats</li><li>Bucket Seat</li><li>Power Windows</li><li>Rear Window Wiper</li><li>Tinted Glass</li><li>AM/FM Radio</li><li>AM/FM Stereo</li><li>CD Changer</li><li>CD Player</li><li>Premium Sound</li><li>Satellite Radio</li><li>DVD</li><li>TV</li><li>Alloy Wheels</li><li>Power Door Locks</li><li>Power Mirrors</li><li>Sunroof</li><li>Third Row Seats</li><li>Power Slide Door</li><li>Custom wheels</li><li>Fully loaded</li><li>Maintenance records available</li><li>New paint</li><li>New tires</li><li>No accidents</li><li>One owner</li><li>Performance tires</li><li>Upgraded sound system</li><li>Turbo</li>', './adpics/AlfaRomeoC8.jpg', './adpics/Alfa-Romeo-8c-Competizione.jpg', './adpics/alfa-romeo-8c.jpg', './adpics/alfa-8c.jpg', './adpics/alfa8c.jpg', './adpics/2003_Alfa_Romeo_8C_Competizione_Concept.jpg', 'nirman');

try this..........!!

---------------------------------------------------------------------------------

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php 
if(isset($_POST['input'])) {
  include("../init/db.php");
  
  $yearfom = $_POST["yearFrom"];
	$yearTo = $_POST["yearTo"];
	
	$Year ="SELECT";
	
	if($yearfom!="SELECT"){
		$Year ="";
		}
	
		$content = array("make"=>$_POST["make"],
					 "model"=>$_POST["model"],
					 "year"=>"$Year");


   
    $validValues=array();

	foreach ($content as $key=>$value)
	{
		if($value != "SELECT")
		  {
			 $validValues[$key]=$value;	
							
		  }
		  
	}
	
	$query ="select * from cars where ";
	foreach($validValues as $key=>$value)
	{

		$query1 = $query.$key."='".$value."' AND ";
		$qu1=true;
		if($key == "year"){
			$query1 = substr($query1,0,-8);
			$query2 = $query1." BETWEEN '".$yearfom."' AND ' ".$yearTo."' ";
			$qu1=false;
			$qu2=true;
			
			}
			
				
	}
	
	if($qu1==true){
	$query = substr($query1,0,-4);
	echo $sql = $query;
	
	}elseif($qu2==true){
		
		$query = $query2;
		echo $sql = $query;
		}		
  
  
// how many rows to show per page
$rowsPerPage = 2;

// 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;
  
 
 
 
 
// $sql= "select * from cars where year BETWEEN '2007' AND ' 2009' ";
  $result=mysql_query($sql);
   $row=mysql_num_rows($result);
     
  while($info=mysql_fetch_array($result)){


    
	 $make = $info['make'];
	  $model = $info['model'];
	  $price = $info['price'];
	  $features = $info['features'];
	  $year= $info['year'];
	  
	 $pic1=$info['pic1'];
	 $pic2=$info['pic2'];
	  $pic3=$info['pic3'];
				   
		   
	  $id = $info['id'];
	  $desc=str_replace ("<li>", "   ", $features);
	  
	   $ftt = substr($desc,0,120)."................."; 
	    $abc="'viewad.php?id=$id'";


echo	'<div id="adcontent"><a  onclick="javascript<b></b>:popUp('.$abc.')"">
	<div id="cars">
  			<div style="background-color:#0091DE; padding:5px; font-weight: bold; color:#FFF;">
   		 '.$make.' - '.$model.' -  '.$year.'
     	    </div>
 			 <div style="padding:10px; font-size: 30px;">
      			<img src="'.$pic1.'" width="20%" height="20%" style="margin:5px;"/>    
   		 		<img src="'.$pic2.'" width="20%" height="20%" style="margin:5px;" />
    			<img src="'.$pic3.'" width="20%" height="20%"style="margin:5px;"/> $ '.$price.' 
             </div>  
  				<div style="padding: 15px;">    
    			<P style="font-size: 12px; font-weight: normal;"> 
     			 '.	$ftt.'      
     				 </P>    
 				 </div>
  				<img src="image/images/carbot.gif" width="500" height="10" />
 			 </div></a>
  
	</div>';
	  
	  }
	


// how many rows we have in database
$foreditqu= substr($sql,19,-1);
echo $foreditqu;

$query   = "SELECT COUNT(id) AS numrows FROM cars ".$foreditqu;
echo $query;
$result  = mysql_query($query) or die('Error, query failed');
$row     = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<br />".$numrows = $row['numrows'];

echo "<br />";
// how many pages we have when using paging?
echo $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;

}
  ?>
<form id="form1" name="F2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <div style="background-color:#84C8FD; text-align: center;">
    <h2>Find a Car</h2>
  </div>
  <table width="224" border="0">
    <tr>
      <td width="42">Make</td>
      <td colspan="2"><label for="make"></label>
        <select name="make" id="master">
          <option value="SILECT">Select</option>
          <option value="AC">AC </option>
          <option value="ALFA ROMEO ">ALFA ROMEO </option>
          <option value="ASIA ">ASIA </option>
          <option value="AMAROO ">AMAROO </option>
          <option value="ASTON MARTIN ">ASTON MARTIN </option>
          <option value="AUDI ">AUDI </option>
          <option value="AUSTIN ">AUSTIN </option>
          <option value="AUSTIN HEALEY ">AUSTIN HEALEY </option>
          <option value="BEDFORD ">BEDFORD </option>
          <option value="BENTLEY ">BENTLEY </option>
          <option value="BERTONE ">BERTONE </option>
          <option value="BMW ">BMW </option>
        </select></td>
    </tr>
    <tr>
      <td>Model</td>
      <td colspan="2"><label for="model"></label>
        <select name="model" id="slave">
          <option value="SELECT">Select</option>
        </select></td>
    </tr>
    <tr>
      <td>Year</td>
      <td width="80"><label for="yearFrom"></label>
        <select name="yearFrom" id="yearFrom">
          <option value="SELECT">From</option>
          <option value="2008">2008</option>
          <option value="2009">2009</option>
        </select></td>
      <td width="80"><select name="yearTo" id="yearTo">
        <option value="SELECT">To</option>
        <option value="2008">2008</option>
        <option value="2009">2009</option>
      </select></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input name="input" type="submit" value="Search" />
        &nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>

this is not working............... sorry

you have one mistake on your start of code.......

include("../init/db.php");

you should use

include("./init/db.php");

rest of code is working all the way fine.........!!

but the db conent are working in this page

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.