MySQL Forums
Forum List  »  PHP

Update returned records with HTML form
Posted by: Mike Swift
Date: September 29, 2020 11:33AM

Hi all,
I am a complete novice and have pinched the following code ,edited it and it works! (to a fashion)

I have the data returned to a webpage but I would like to add data to the returned records on that webpage and submit the new data.

So the form below will return , firstname , lastname , address1, etc, etc, and I would like to be able to have a couple of empty fields in the form where I can add delivery tracking number and postage cost to each record returned.

Can someone please help . I hope I have made sense.

Thanks in advance.

I have :
<form action="phpsearchoption.php" method="post">
<center><H2>Search the winners<p>
To use this search <p>
Select what to search for in the dropdown box.<p>
To search on the date field use this format 2020-09-07 <br>
or to search for all winners in say, September use 2020-09 <p>


<tr><td>Select what to search for: </td><td><select name="column">

<option value="lastname">Last Name</option>
<option value="firstname">First Name</option>
<option value="email">Email Address</option>
<option value="productname">Prize Won</option>
<option value="price">Ticket price</option>
<option value="winner_date">Won Date</option></select></td></tr>

<tr><td>Insert a search term <br>(name , part of name, date, Driver etc: </td><td><input type="text" name="search"></td></tr></table>

<input type ="submit">




$search = $_POST['search'];
$column = $_POST['column'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "databasename";
$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error){
die("Connection failed: ". $conn->connect_error);

$sql = "SELECT * from
WHERE $column like '%$search%'AND idcustomer LIKE winner";

echo "<table border =1 width=75%>";
echo "<tr>";
echo "<th>Name: </th>";
echo "<th>address: </th> ";
echo "<th>address2: </th> ";
echo "<th>County: </th> ";
echo "<th>Post Code: </th> ";
echo "<th>Email: </th> ";
echo "<th>Tel no: </th> ";
echo "<th>Prize Won: </th>";
echo "<th>Ticket Price: </th>";
echo "<th>Date Listed: </th>";
echo "<th>Date Won: </th>";
echo "</tr>";
echo "</table><p>";
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while($row = $result->fetch_assoc() ){

echo "<table>";
echo "<tr>";
echo "<td><b>".$row["firstname"]." ".$row["lastname"]." ,</b></td>";
echo "<td>".$row["address1"].",</td>";
echo "<td>".$row["address2"].",</td>";
echo "<td>".$row["county"].",</td>";
echo "<td>".$row["postcode"].",</td>";
echo "<td><b>".$row["email"].",</b></td>";
echo "<td>".$row["phonenumber"].",</td>";
echo "<td><b>".$row["productname"].",</b></td>";
echo "<td> £".$row["price"].",</td>";
echo "<td><b>".$row["avaliable_dt"].",</b></td>";
echo "<td>".$row["winner_date"]."</td>";
echo "</tr>";
echo "</table><p>";

} else {
echo "There are no winners meeting that search criteria";



Options: ReplyQuote

Written By
Update returned records with HTML form
September 29, 2020 11:33AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.