Build a dynamic Webpage using PHP similar to realestae inquiry Assume that the t
ID: 3550649 • Letter: B
Question
Build a dynamic Webpage using PHP similar to realestae inquiry
Assume that the table already set up
The entry point of the site is a form with a drop-down list and a text field asking the user to choose:
q City (drop-down list): populated dynamically by the cities in the table
q Maximum price for the house (text field): empty when we start
q Maximum taxes for the house (text field): empty when we start
When the user clicks on "Submit", you should return a table of houses meeting all the user's criteria and showing for each: the city where it is located, the number of bedrooms, the number of bathrooms, its price, whether there is a parking or not, and the property taxes. The table should be a real HTML table . The houses should be ordered by price in descending order
A table (houses) has already been set up for you in the database ct406s14. The format and the contents of that table are attached.
Explanation / Answer
I have put lot off efforts for your problem
<?php
//here Inquiry is database
//house is table name in Inquiry database
$con= mysqli_connect('localhost','root','','Inquiry');
$result=mysqli_query($con,"select city from house");
?>
<html>
<head>
</head>
<body>
<form id="myform" action="show.php" method="post" >
<select name="city">
<option name="city" value="">Select City</option> //populate dynamically
<?php
while($value=mysqli_fetch_array($result,MYSQL_ASSOC))
{
echo "<option>".$value['city']."</option>";
}
mysqli_close($con);
?>
</select><br/>
Maximum Price for House:<input type="text" id="txt1box" value=""/><br>
Maximum Price for House: <input type="text" id="txt2box"value=" "/>
</form>
</body>
</html>
/*****************************************show.php*******************************
<?php
//It is show.php file
$city=$_POST['city'];
$first_name=$_POST['txt1box'];
$last_name=$_POST['txt2box'];
$con= mysqli_connect('localhost','root','','Inquiry');
$result=mysqli_query($con,"select * from house where city=".$city);
?>
<html>
<body>
<center>
<h1>Employee Information<h1>
<table border="2" width="600" height="400">
<tr>
<th>S.No</th>
<th>Location</th>
<th>No of Bedrooms</th>
<th>No of Bathrooms</th>
<th>Parking</th>
<th>Price</th>
<th>Property tax</th>
</tr>
<?php
foreach( $result as $data ) {
echo "<tr>
<td>" . $s_no++. "</td>
<td>" . $data['location'] . "</td>
<td>" . $data['Bedrooms'] . "</td>
<td>" . $data['Bathrooms'] . "</td>
<td>" . $data['Parking'] . "</td>
<td>" . $data['Price'] . "</td>
<td>" . $data['Property_tax'] . "</td>
</tr>";
}
mysqli_close($con);
?>
</table>
<center>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.