Search the Community
Showing results for tags 'booking system'.
-
HI I'm creating a booking system in PHP that allows estate agents to book viewings for houses. I am having a slight issue. The concept is simple, a user searches for the property using postal code, the database then returns the property results. The user then ticks a checkbox next to the property they want to add the viewing for. This is where the issue is occurring. Each property has an ID. The ID is assigned to the name="" element in the HTML. I'm now not sure where to go from here. What I want is this, once the user selects the property, the property ID for the selected row needs to be stored so that I can use it later on in the booking. Here is the part of the Code I have. $newrecord = "Here are the results"; if (isset($_POST['submitted'])) { $PostCode = $_POST['PostCode']; $error; $checkpostcode = "SELECT * from PropertyTable WHERE PostCode = '$PostCode'"; $resultpostcode = mysql_query($checkpostcode); $count = mysql_num_rows($resultpostcode); if ($count == 0) { $_POST["PostCode"] = $PostCode; echo 'Sorry no properties were found with this Post Code. Please check it is entered correctly, then try again.'; } else { //show options $selectproperty ="SELECT * from PropertyTable WHERE PostCode = '$PostCode'"; $propertyresults = mysql_query($selectproperty); echo"<div class='page-restrict-output'>"; echo "<form method='post' action='add-viewing'>"; echo "<input id='addviewingbutton' type='Submit' name='addviewingbtn' value='Select Property' /><br><br /></td></tr>"; echo"<table id='selectviewingtable' border='1'>"; echo "<tr><th>Property Name</th><th>Post Code</th><th>Property ID</th><th>Add Viewing</th></tr>"; while($row = mysql_fetch_array($propertyresults)) { echo "<tr><td>"; echo $row['PropertyName']; echo "</td><td>"; echo $row['PostCode']; echo "</td><td>"; echo $row['ProductID']; echo "</td><td>"; echo $row['SelectViewing']; echo "<input id='selectviewingbutton' type='checkbox' name='$row[ProductID]' value='True' /></td></tr>"; echo" </form>"; echo "</div>"; } } } if (isset($_POST['addviewingbtn'])) { foreach ($_POST as $key => $value){ if ($value="True"){ $ProductId = $key; } } $choseproperty = "SELECT ProductID from PropertyTable WHERE '$row[ProductID]' = True"; $chosenpropertyresults = mysql_query($choseproperty); while($row = mysql_fetch_array($chosenpropertyresults)) { } print_r($_POST); echo "$chosenproperty"; } else { } Using print_r I get Array ( [addviewingbtn] => Select Property [4] => True ). The [4] is the property ID, this changes on which item you select. I'm just a bit lost here. I'm still getting to grips with PHP and any help would be much appreciated.