Location: PHPKode > projects > Apartment Classfieds > apartment_classifieds_script/index.php
<?php
require_once('class_apartment.php');
require_once('class_category.php');
require_once('class_database.php');
require_once('class_page.php');
require_once('globals.php');

$page = null;
$categories = null;
$db = null;
$total_rows = null;

$page = new Page();
$page->append_title('Free Apartment Listings');
$db = new Database();
if (!$db->connect())
{
	die('Fatal error: could not connect to database.');
}

Category::get_categories($categories, $db->get_handle());
$page->append_content('To start, please select a category from the list below:');

$page->append_content('<ul>');
for ($i = 0; $i < count($categories); $i++)
{
	$total_rows = Apartment::search_category_total_rows($categories[$i]->get_id(), $db->get_handle());

	$page->append_content('<li><a href="apartment_search.php?category_id='.$categories[$i]->get_id().'&amp;offset=0">'.$categories[$i]->get_title().'</a> ('.$total_rows.' posts)</li>');
}
$page->append_content('</ul>');

$page->display();
?>
Return current item: Apartment Classfieds