I'm new to this forum and I would like to thank everyone in advance for the help. I've got a drop down menu where someone can make the selection and I need it to display in a table using HTML_Table, but all I get is the headers. I'm providing the code down below can someone please help me? Thanks.
<?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 `apartments` WHERE `county` = '".$county."' AND `rooms` = '".$rooms."' AND `rent` < '".$rent."' AND `rent` > '".$rent_min."' ";
}else{
$sql = "SELECT * FROM `apartments`";
}
$res = mysql_query($sql, $dbase);
require_once 'HTML/Table.php';
$attrs = array('width' => '600');
$table = new HTML_Table();
$table->setAttributes($attrs);
for ($nr = 0; $nr < count($data); $nr++) {
$table->setHeaderContents($nr+1, 0, (string)$nr);
for ($i = 0; $i < 4; $i++) {
if ('' != $data[$nr][$i]) {
$table->setCellContents($nr+1, $i+1, $data[$nr][$i]);
}
}
}
$altRow = array('bgcolor' => '#999969');
$table->altRowAttributes(1, null, $altRow);
// Create the table object
$table = new HTML_Table();
// Set the headers
$table->setHeaderContents(0, 0, "County");
$table->setHeaderContents(0, 1, "Town");
$table->setHeaderContents(0, 2, "Phone");
$table->setHeaderContents(0, 3, "Rooms");
$table->setHeaderContents(0, 4, "Bath");
$table->setHeaderContents(0, 5, "Rent");
$hrAttrs = array('bgcolor' => '#333333');
$table->setRowAttributes(0, $hrAttrs, true);
$table->setColAttributes(0, $hrAttrs);
$rownum = 1; // don't overwrite header of table
while($row = mysql_fetch_assoc($res))
$table->altRowAttributes(1, null, array("class"=>"alt"));
// Output the data
echo $table->toHtml();