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);
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Attached you have your answer.
You might need to change some stuff, and fix errors, but basically this is all you need index.php
You might need to change some stuff, and fix errors, but basically this is all you need index.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys but Hexer4u had the best solution thanks!
ASKER
Just a quick question but what do I put in these fields
$where = '';
$get = '';
$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.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_4742-Simple-PHP-pagination.html