I am trying to build a real estate page where users could select a location
and then all listings associated with that listing will be displayed.  For
some reason the drop down menu is working.  

Any help will be appreciated and please find the code below;

 

<?php # Script

 

$page_title = 'View Locations';

include ('./includes/header.html');

require_once ('./connections/mysql/mysql_connect.php'); // Connect to the
database.

 

// Create a form allowing the user to select a URL category to view.

echo '<div align="center">

<form method="get" action="browse_byloc4.php">

<select name="type">

<option value="NULL">Choose a Location:</option>

';

 

// Retrieve and display the available categories.

$query = 'SELECT DISTINCT location AS location FROM apartments ORDER BY
location ASC';

$result = mysql_query ($query);

while ($row = mysql_fetch_array ($result, MYSQLI_ASSOC)) {

echo "<option value=\"$row[0]\">$row[1]</option>

";

}

 

// Complete the form.

echo '</select>

<input type="submit" name="submit" value="Go!">

</form>

</div>

';

 

// Retrieve the URLs for a particular category, if selected.

// Make sure the type is an integer.

if (isset($_GET['type'])) {

            $type = (int) $_GET['type'];

} else {

            $type = 0;

}

 

if ($type > 0) {

 

            // Get the current type name.

            $query = "SELECT * FROM apartments WHERE location=$type";

            $result = mysql_query ($query);

            list ($location) = mysql_fetch_array ($result, MYSQL_NUM);


            

            $tmp_num_cols = $_GET['num_cols'];

            

echo '<table border="0" width="90%" cellspacing="0" cellpadding="0"
align="center"><tr><td height="300"><table width="100%" height="100%"
border="0"><tr>';

 

// START OUR GRID CODE

$num_columns = 3; // SET THE NUMBER OF COLUMNS TO DISPLAY TO 3

$column_counter = 1; // COUNTS OUR CURRENT COLUMN

 

// Display all the prints, linked to URLs.

$result = mysqli_query ($dbc, $query); // GET ALL THE apartmentS FROM THE DB

while ($apartment = mysqli_fetch_array ($result, MYSQL_ASSOC)) { // Display
each record.

echo '<td height="100%"><table width="150" height="60%" border="3"
cellpadding="0" cellspacing="0"><tr><td align="right">';

 

if ($image = getimagesize ("../uploads/{$apartment['image_name']}")) 

{

echo "<img width=190 height=110
src=\"../uploads/{$apartment['image_name']}\" $image[9]
alt=\"{$apartment['apartment_name']}\"/><br>";

}

 

echo "<a
href=\"view_print.php?pid={$apartment['apartment_id']}&aName={$apartment['ap
artment_name']}&aPrice={$apartment['price']}\">{$apartment['apartment_name']
}</a><br>\${$apartment['price']}</td></tr>";

echo '</table></td>';

if ($column_counter == $num_columns) { // IF WE'VE REACHED THE END OF OUR
ROW

echo '</tr></table></td></tr>

<tr><td><hr></td></tr>

<tr><td height="300"><table width="100%" height="100%" border="0"><tr>';

$column_counter = 0;

}

$column_counter++;

} 

}

// End of while loop.

echo '</tr></table></td></tr></table>'; // Close the table.

 

include ('./includes/footer.html');

?>

 

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to