I have a form with a select box where the user can select pre-existing fields from a database:
<form action='' method='POST' autocomplete='off' enctype="multipart/form-data">
<p><strong>Title and Description:</strong></p>
<select name='uidtitle' class='chosen-select'>
<option value="0" ></option>
<?php
$result = $mysqli->query("SELECT uid, title, description FROM tblFacilityHrs") or die($mysqli->error);
while ($row = $result->fetch_array(MYSQLI_ASSOC)){
echo "<option value=\"1\">" . $row['title'] ." - " . $row['description'] . "</option>";
$uid = $row['uid'];
$title = $row['title'];
$desc = $row['description'];
}
?>
</select>
...
How can I send all three of those values (separately) to my postback for SQL?
if (isset($_POST['submitted'])) {
//Get params for prepared statements
$startDatec= date("Y-m-d H:i:s", strtotime($_POST['startEventDate']));
$endDatec= date("Y-m-d H:i:s", strtotime($_POST['endEventDate']));
$startTimec=$_POST['startTime'];
$endTimec=$_POST['endTime'];
$recurc=$_POST['recurrence'];
$finalc= date("Y-m-d H:i:s", strtotime($_POST['finalDate']));
...
I have no idea why you would need to send all three values back. Database Keys exist for the reason of being able to identify ALL fields in a record given just a single field, in this case I’m assuming
uid. Passing that field alone would allow you to select the other fields in your postback before performing the operation that you intend.However, it is possible using hidden form fields, although I don’t advocate this approach.
The hidden form fields will be present for all records in your
tblFacilityHrstable. The names are made distinct by appending theuidto the name. You can determine what fields you are interested in in your postback by: