I am about to give up and start bashing my head against the wall. I feel I must have made some grave mistake in all of my coding for a website I built for my family's real estate company, and the site is supposed to launch tomorrow...:queasy:
First I want to put it out there that the websites runs perfectly on my laptop. It is a MacBook Pro running leopard and has versions 5 of php and mysql installed on it.
The servers I am hosting the site on are Linux and supposedly running version 5 of php and mysql....
I uploaded the website onto the servers...everything looks like it is running smoothly. Except!!!!! On the property listings page its not displaying the properties. At first I thought maybe it had something to do with the mysqli extensions, but the other pages on the site use them to call up the content stored in the database and it works just fine.
I think it has something to do with the fetch array and making the tables.
Am I doing something wrong...or is this the fault of the servers? Help?
<?php
require_once ('../../realview_connect.php');
// Number of records to show per page:
$display = 10;
// Determine how many pages there are:
if (isset($_GET['p']) && is_numeric($_GET['p'])) {// Already been determined.
$pages = $_GET['p'];
} else { // Need to determine.
// Count the number of records:
$q = "SELECT COUNT(property_id) FROM properties WHERE type='sale' AND active='yes'";
$r = @mysqli_query ($dbc,$q);
$row = @mysqli_fetch_array ($r,MYSQLI_NUM);
$records = $row[0];
// Count the number of pages...
if($records > $display) {// More than 1 page.
$pages = ceil ($records/$display);
} else {
$pages = 1;
}
} // End of p IF.
//Determine where in the database to start returning reslts...
if (isset($_GET['s']) && is_numeric($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
// Default column links.
$link1 = "{$_SERVER['PHP_SELF']}?sort=costa";
$link2 = "{$_SERVER['PHP_SELF']}?sort=citya";
// Determine the sorting order.
if (isset($_GET['sort'])) {
// Use existing sorting order.
switch ($_GET['sort']) {
case 'costa':
$order_by = 'cost ASC';
$link1 = "{$_SERVER['PHP_SELF']}?sort=costd";
break;
case 'costd':
$order_by = 'cost DESC';
$link1 = "{$_SERVER['PHP_SELF']}?sort=costa";
break;
case 'citya':
$order_by = 'city ASC';
$link2 = "{$_SERVER['PHP_SELF']}?sort=cityd";
break;
case 'cityd':
$order_by = 'city DESC';
$link2 = "{$_SERVER['PHP_SELF']}?sort=citya";
break;
default:
$order_by = 'city DESC';
break;
}
// $sort will be appended to the pagination links.
$sort = $_GET['sort'];
} else { // Use the default sorting order.
$order_by = 'city DESC';
$sort = 'cityd';
}
// Make the query:
$q = "SELECT * FROM properties WHERE type='sale' AND active='yes' ORDER BY $order_by LIMIT $start, $display";
$r = @mysqli_query ($dbc, $q); // Run the query.
// Table header.
echo '<br /><br />
<h2>Order properties by <a href="' . $link1 . '">price</a> or by <a href="' . $link2. '">city</a></h2><h3><p>
';
// Fetch and print all the records:
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$full = $row['bath_full'];
$half = $row['bath_half'];
$three = $row['bath_three'];
$baths = $full + $half + $three;
$price = number_format ($row['cost']);
// table header
echo '<table class="listing" cellpadding="0" cellspacing="0" width="95%">';
// print main_pic
echo'<tr>
<td width="168" rowspan="5" colspan="0">
<a href="flyer.php?id=' . $row['property_id'] . '" target="_blank"><img src="../../uploads/' . $row['main_pic'] . '" border="0" width="168"></a>
</td>
</tr>';
// print description
echo'<tr>
<td align="right"><a href="http://www.mapquest.com/maps?city=' . $row['city'] . '&state=CO&address=' . $row['street_number'] . '+' . $row['direction'] . '+' . $row['street'] . '+' . $row['kind'] . '" target="_blank">Map it!</a>';
echo'</td>
</tr>
<tr>
<td align="center">
' . $row['city'] . '<br>
<a href="flyer.php?id=' . $row['property_id'] . '" target="_blank">'.$row['street_number'].' '.$row['direction'].' '.$row['street'].' '.$row['kind'].'</a><br>
' . $row['beds'] . ' Beds and ' . $baths . ' Baths<br>
' . $row['sqft'] . ' sqft<br>
$' . $price . '
</td>
</tr>
</table>
<br>';
} // End of WHILE loop
mysqli_free_result ($r); // Free up the resources.
mysqli_close($dbc); // Close the database connection.
// Make links to other pages if necessary.
if ($pages > 1) {
// Add some spcing to start paragraph:
echo' <br /><p>';
// Determine what page the scrip is on
$current_page = ($start/$display) +1;
// If its not the first page make a previous button:
if ($current_page !=1) {
echo '<a href="properties.php?s=' . ($start - $display) . '&p=' . $pages . '$sort=' . $sort . '">Previous </a>';
}
// Make all Numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="properties.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '$sort=' . $sort . '">' . $i . '</a>';
} else {
echo $i . '';
}
} // End of FOR loop
// If its not the last page, make a next button:
if ($current_page != $pages) {
echo ' <a href="properties.php?s=' . ($start + $display) . '&p=' . $pages . '$sort=' . $sort . '"> Next</a>';
}
echo '</p>'; // Close the paragraph.
} // End of links selection
?>