16 Replies - 813 Views - Last Post: 24 August 2011 - 06:06 PM
#1
Advanced Form.
Posted 24 August 2011 - 04:00 PM
Replies To: Advanced Form.
#2
Re: Advanced Form.
Posted 24 August 2011 - 04:08 PM
What exactly is an "advance form"? What are you looking for it to do? What have you tried thus far?
#3
Re: Advanced Form.
Posted 24 August 2011 - 04:15 PM
I have a form that will enable people to search for there desired property based on different criteria. The form is working.. and the search is working as well but the problem is that if a user does not fill in all the details in the form , it wont work. So i am looking for a way to modify the search so that it can retrieve information's even when a user decides to skip some of its fields or even when the fields are empty.
Here is the code:
Here is the code for the form:
<?php
//include PHP script with MySQL parameters defined
require "database.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Property Search</title>
<!-- Link to our style sheets-->
<link rel="stylesheet" type="text/css" href="css/search.css">
</head>
<body>
<form name="search" method="post" action="property_search.php" onsubmit="return validate();">
<table>
<tr>
<th colspan="2" style="font-size:20px" > Quick Search </th>
</tr>
<!--location of the property-->
<tr style="height:50px">
<th>Location: </th>
<td>
<?php
$query = "SELECT DISTINCT State FROM Property_Details ORDER BY State ASC";
$result = mysql_query($query);
echo "<select name=state>";
echo "<option value=\"\">--Choose--</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['State']."\">".$row['State']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<!--property_type(Menu to choose weather the property is for sale or to rent-->
<tr style="height:50px">
<th>Type: </th>
<td>
<?php
$query = "SELECT DISTINCT Property_Type FROM Property_Details ORDER BY Property_Type ASC";
$result = mysql_query($query);
echo "<select name=propertyType>";
echo "<option value=\"\">--Choose--</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Type']."\">".$row['Property_Type']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<!--Property Category(Menu to choose weather the property is for Flat, Bungalow etc-->
<tr style="height:50px">
<th>Category: </th>
<td>
<?php
$query = "SELECT DISTINCT Property_Category FROM Property_Details ORDER BY Property_Category ASC";
$result = mysql_query($query);
echo "<select name=propertyCatagory>";
echo "<option value=\"\">--Choose--</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Category']."\">".$row['Property_Category']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr style="height:50px">
<th>Rooms: </th>
<td>
<?php
$query = "SELECT DISTINCT Number_Of_Rooms FROM Property_Details ORDER BY Number_Of_Rooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_rooms>";
echo "<option value=\"\">Min No.of Rooms</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Rooms']."\">".$row['Number_Of_Rooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
<?php
$query = "SELECT DISTINCT Number_Of_Rooms FROM Property_Details ORDER BY Number_Of_Rooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_rooms_2>";
echo "<option value=\"\">Max No.of Rooms</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Rooms']."\">".$row['Number_Of_Rooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr style="height:50px">
<th>Bathrooms: </th>
<td>
<?php
$query = "SELECT DISTINCT Number_Of_Bathrooms FROM Property_Details ORDER BY Number_Of_Bathrooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_br>";
echo "<option value=\"\">Mini No.of Baths</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Bathrooms']."\">".$row['Number_Of_Bathrooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
<?php
$query = "SELECT DISTINCT Number_Of_Bathrooms FROM Property_Details ORDER BY Number_Of_Bathrooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_br_2>";
echo "<option value=\"\">Max No.of Baths</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Bathrooms']."\">".$row['Number_Of_Bathrooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr style="height:50px">
<th>Price: </th>
<td>
<?php
$query = "SELECT DISTINCT Property_Price FROM Property_Details ORDER BY Property_Price ASC";
$result = mysql_query($query);
echo "<select name=price>";
echo "<option value=\"\">Minimum Price</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Price']."\">".$row['Property_Price']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
<?php
$query = "SELECT DISTINCT Property_Price FROM Property_Details ORDER BY Property_Price ASC";
$result = mysql_query($query);
echo "<select name=price_2>";
echo "<option value=\"\">Maximun Price</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Price']."\">".$row['Property_Price']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td colspan="2">
<button type="search" name="submit"> Search </button>
<button type="reset" value="Reset" />Clear </button>
</td>
</tr>
</table>
</form>
</body>
</html>
And here is the property_search.php
<?php
//include PHP script with MySQL parameters defined
require "database.php";
?>
<html>
<head>
<!-- title of our web page-->
<title>Search For Property</title>
<!--***The W3C validator like the encoding and content-type specified.-->
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<!-- Link to our style sheets-->
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/property.css">
</head>
</body>
<!-- include the file for the top Navigation-->
<?php include("topnav.html"); ?>
<div id="properties">
<?php
//include PHP script with MySQL parameters defined
require "database.php";
//This gets all the other information from the form
$state=$_POST['state'];
$propertyType=$_POST['propertyType'];
$property_catagory=$_POST['propertyCatagory'];
$no_of_rooms=$_POST['no_of_rooms'];
$no_of_rooms_2=$_POST['no_of_rooms_2'];
$no_of_br=$_POST['no_of_br'];
$no_of_br_2=$_POST['no_of_br_2'];
$price=$_POST['price'];
$price_2=$_POST['price_2'];
// compose SQL query and execute
$query=" SELECT * FROM Property_Details WHERE State='$state'
AND Property_Type='$propertyType'
AND Property_Category='$property_catagory'
AND Number_Of_Rooms BETWEEN '$no_of_rooms' AND '$no_of_rooms_2'
AND Number_Of_Bathrooms BETWEEN '$no_of_br' AND '$no_of_br_2'
AND Property_Price BETWEEN '$price' AND '$price_2' ORDER BY Date DESC";
$result=mysql_query($query,$link);
//
// process query result
//
if ($result==null)
{
echo "No property found.<br>\n";
}
else {
//generate table of properties.
print "<table class=\"thin-outline\">\n";
while ($row=mysql_fetch_array($result))
{
print "<tr>";
print "<td colspan=\"2\" style=\"font-style:italic;font-weight: bold; font-size:25px\">" .$row["State"]. "</td>";
print "<td style=\"font-style:italic;font-weight: bold; font-size:25px\">".$row["Property_Price"]."</td>";
print "</tr>";
print "<tr>";
print "<td><a href=\"propertyDetails.php?id=".$row["Property_Id"]."\"><img src='Images/properties/".$row["Img1"]."'
style=\"border-right-style: solid; border-right-width: 5px; border-right-color: #000; border-bottom-style: solid;
border-bottom-width: 5px; border-bottom-color: #000; margin-right: 1em; margin-bottom: 1em; width:300px; height:150px\"/>
</td>";
print "<td style=\"font-weight: bold\">" .$row["Property_Category"] ."\n<p>"
.$row["Property_Description"].
"</td>";
//generate a hyperlink with the correct parameter
print "<td style=\"font-style:italic;font-weight: bold; font-size:18px\">";
print "<ul>";
print "<li> <a href=\"propertyDetails.php?id=".$row["Property_Id"]."\">More Details</a> </li>";
print "<li> <a href=\"contact_us.html\">Contact Agent</a> </li>";
print "</ul>";
print "</td>";
print "</tr>\n";
}
print "</table>\n";
}
mysql_close($link);
?>
</div>
<!-- include the file for the footer-->
<?php include("footer.html"); ?>
#5
Re: Advanced Form.
Posted 24 August 2011 - 04:31 PM
#6
Re: Advanced Form.
Posted 24 August 2011 - 04:37 PM
#7
Re: Advanced Form.
Posted 24 August 2011 - 05:43 PM
#8
Re: Advanced Form.
Posted 24 August 2011 - 05:46 PM
#9
Re: Advanced Form.
Posted 24 August 2011 - 05:49 PM
#10
Re: Advanced Form.
Posted 24 August 2011 - 05:50 PM
#11
Re: Advanced Form.
Posted 24 August 2011 - 05:53 PM
#12
Re: Advanced Form.
Posted 24 August 2011 - 05:56 PM
#13
Re: Advanced Form.
Posted 24 August 2011 - 05:57 PM
#14
Re: Advanced Form.
Posted 24 August 2011 - 06:03 PM
Quote
Not much, in all honesty. If you can instantiate an object and invoke a method from it, then you're good. It's maybe a couple minor syntax things. That's it.
Also, let's keep things on-topic here and leave the rule enforcing to the moderation team please.
#15
Re: Advanced Form.
Posted 24 August 2011 - 06:05 PM
|
|

New Topic/Question
Reply



MultiQuote









|