Link to home
Start Free TrialLog in
Avatar of genesisvh
genesisvh

asked on

Paginate and alternate colors for rows?

I'm trying to Paginate this using php but I can't figure this for the life of me. Also I'm trying to make each row and alternate color as well. Can anyone help?
<?php

if ($_POST){

	$county = $_POST['county'];
	$rooms = $_POST['type'];
	$rent = $_POST['rent'];
	$rent_min = $rent - 500;
}
	
	$dbase = mysql_connect ( 'localhost', '', '' );
	mysql_select_db ( '', $dbase );
			
	if($county){
		$sql = "SELECT * FROM `` WHERE `county` = '".$county."' AND `rooms` = '".$rooms."' AND `rent` < '".$rent."' AND `rent` > '".$rent_min."' ";
	}else{
		$sql = "SELECT * FROM ``";
	}			
	
	$res = mysql_query($sql, $dbase);
	echo "<strong>Click Headers to Sort</strong>";
	echo "<table border='0' align='center' bgcolor='#999969' cellpadding='3' bordercolor='#000000'> 
<tr>
<th> Title </th> 
<th> County </th> 
<th> Town </th> 
<th> Phone </th> 
<th> Rooms </th> 
<th> Bath </th> 
<th> Rent </th>
</tr>";
				
		while($row = mysql_fetch_assoc($res))
				  {
echo "<tr>
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>
		   <a href='classified/searchapts/index.php?id=".$row['id']."'>" . $row['title'] . "</a></td>;
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['county'] . "</td> 
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['town'] . "</td> 
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['phone'] . "</td> 
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rooms'] . "</td> 
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['bath'] . "</td> 
		<td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rent'] . "</td>
</tr>"; 

}

echo "</table>"; 
			
	print_r($apts);


?>

Open in new window

Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

SOLUTION
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hexer4u
Attached you have your answer.
You might need to change some stuff, and fix errors, but basically this is all you need index.php
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of genesisvh
genesisvh

ASKER

Thanks guys but Hexer4u had the best solution thanks!
Just a quick question but what do I put in these fields
$where = '';
$get = '';
Nothing. Leave them be. They are default values that specify what should the query search for when nothing is specified. It basically means everything.