Hi all,
I am trying to populate a form from MySQL using a dropdown menu to select the row I want displayed.
The dropdown is displaying the items I need. But what I want to do is select one of the items in the dropdown, which will fill in the form with the items I need for editing.
Here is the code I have so far, including the form. Any help you guys can give would be really appreciated.
The Select:
<div class="panel panel-primary">
<div class="panel-heading"> Manage Tours</div>
<div class="panel-body">
<form role="form" method="post" action="">
<label for="singleSelect">Choose Tour to Edit</label>
<select class="form-control" name="tour_select">
<?php
$result = mysqli_query($mysqli,"SELECT tour_name FROM tours order by id");
while($row = mysqli_fetch_array($result))
echo "<option value='" . $row['tour_name'] . "'>" . $row['tour_name'] . "</option>";
?>
</select>
This works fine.
The form, which also works fine with a simple select query:
<div class="form-group">
<label>Tour Name</label>
<input class="form-control" name="tour_name" value="<?php echo $row['tour_name']; ?>" />
</div>
<div class="form-group">
<label>Destination</label>
<textarea class="form-control" name="tour_to" rows="4"><?php echo $row['tour_to']; ?></textarea>
</div>
<div class="form-group">
<label>Collection</label>
<textarea class="form-control" name="tour_from" rows="4"><?php echo $row['tour_from']; ?></textarea>
</div>
<div class="form-group">
<label>Date</label>
<input class="form-control" name="tour_date" value="<?php echo $row['tour_date']; ?>" />
</div>
<div class="form-group">
<label>Pickup Time</label>
<input class="form-control" name="tour_time" value="<?php echo $row['tour_time']; ?>" />
</div>
<div class="form-group">
<label>Itinerary</label>
<textarea class="tinymce" id="tinymce" name="tour_details" rows="12" ><?php echo $row['tour_details']; ?></textarea>
</div>
<button type="submit" name="Submit" class="btn btn-primary">Save Changes</button>
</form>
But, when I select an option from the dropdown, I need the form to be populated with the data from that database table row. I hope I am making sense.
I have searched for days on Google but found nothing.
I have changed the form from a dropdown to an html table with a Delete button.
Here is the code with table:
<?php
if (isset($_GET['id'])) {
if (isset($_POST['Delete'])) {
$remove = $mysqli->prepare("DELETE FROM `tours` WHERE `id` = $id");
$id = $_POST['id'];
$remove->bind_param('ssssss', $id);
if(!$remove->execute() === true) {
echo $mysqli->error;
}
}
}
$sql = "SELECT * FROM tours";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<tbody>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['tour_name']; ?></td>
<td><?php echo $row['tour_to']; ?></td>
<td><?php echo $row['tour_from']; ?></td>
<td><?php echo $row['tour_date']; ?></td>
<td><?php echo $row['tour_time']; ?></td>
<td><input type="submit" name="Delete" value="Delete" onclick="" /></td>
</tr>
</tbody>
<?php
}
?>
</table>
</form>
I appreciate any help.
Say you want to preselect a particular tour with $tour_id = 5. You can then modify your code to:
echo "<option value='" . $row['tour_name'] . "'" . ($row['id'] == $tour_id ? " selected" : "") . ">" . $row['tour_name'] . "</option>";
I have found the solution should anyone need it in future.
<?php
if (isset($_POST['Delete'])){
$checkbox = $_POST['checkbox'];
$count = count($checkbox);
for($i=0;$i<$count;$i++){
if(!empty($checkbox[$i])){ /* CHECK IF CHECKBOX IS CLICKED OR NOT */
$id = mysqli_real_escape_string($mysqli,$checkbox[$i]); /* ESCAPE STRINGS */
mysqli_query($mysqli,"DELETE FROM tours WHERE id = '$id'"); /* EXECUTE QUERY AND USE ' ' (apostrophe) IN YOUR VARIABLE */
} /* END OF IF NOT EMPTY CHECKBOX */
} /* END OF FOR LOOP */
} /* END OF ISSET DELETE */
$sql = "SELECT * FROM tours";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$id = mysqli_real_escape_string($mysqli, $row['id']);
?>
<tbody>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['tour_name']; ?></td>
<td><?php echo $row['tour_to']; ?></td>
<td><?php echo $row['tour_from']; ?></td>
<td><?php echo $row['tour_date']; ?></td>
<td><?php echo $row['tour_time']; ?></td>
<?php echo "<td><input type='checkbox' name='checkbox[]' value='$id'></td>"; ?>
</tr>
</tbody>
<?php
}
?>
Thanks all for the help. Really appreciate it.
Related
So I've been doing this school project and need to make it so I can edit whatever is in the table. Whenever i click on "Edit" it redirects me correctly but in the form it says there is an undefined variable eventhough that variable is used pretty much everywhere.
Here is some code of the table:
<table style='margin-left:auto ; margin-right:auto;'>
<tr>
<th>#</th>
<th>Name</th>
<th>Zeit</th>
<th>Datum</th>
<th>Titel</th>
<th>Inhalt</th>
<th>Ort</th>
</tr>
<?php
if($stmt=$db->prepare("SELECT * FROM terminkalender")) {
$stmt->execute();
$stmt->store_result();
$zeilen = $stmt->num_rows();
$stmt->close();
}else {
$zeilen = 0;
}
if($zeilen > 0) {
//nur wenn Einträge, dann ausgeben
if($stmt = $db->prepare("SELECT * FROM terminkalender ORDER BY zeit,datum DESC")) {
$stmt->execute();
$stmt->bind_result($id,$name,$zeit,$datum,$ort,$titel,$inhalt);
$stmt->store_result();
//Ausgabe starten
while($stmt->fetch()){
echo "<tr>";
?>
<td><?php echo $id ;?></td>
<td><?php echo htmlspecialchars($name) ;?></td>
<td><?php echo htmlspecialchars($datum) ;?></td>
<td><?php echo htmlspecialchars($zeit) ;?></td>
<td><?php echo htmlspecialchars($ort) ;?></td>
<td><?php echo htmlspecialchars($titel) ;?></td>
<td><?php echo htmlspecialchars($inhalt); ?></td>
<td><a href='edit.php?id=<?php echo $id;?>'>Edit</a></td>
<td><a href='delete.php?id=<?php echo $id;?>'>Delete</a></td>
<?php
echo "</tr>" ;
}
}
}
?>
</table>
and here for the edit.php file:
<?php
include("./config/connect.inc.php");
$id = $_GET['id']; // get id through get string
$result=mysqli_query($db,"SELECT * FROM terminkalender WHERE id=$id");
if(isset($_POST['update'])) {
$name=$_POST['name'];
$datum=$_POST['datum'];
$zeit=$_POST['zeit'];
$ort=$_POST['ort'];
$titel=$_POST['titel'];
$inhalt=$_POST['inhalt'];
$result = "UPDATE terminkalender
SET name='$name',
datum='$datum',
zeit='$zeit',
ort='$ort',
titel='$titel',
inhalt='$inhalt'
WHERE id=$id";
header("location: ausgabe.php");
}
?>
<form name="form" method="POST" action="edit.php">
<input type="text" name="name" value="<?php echo $name; ?>" Required>
<input type="date" name="datum" value="<?php echo $datum; ?>" Required>
<input type="time" name="zeit" value="<?php echo $zeit; ?>" Required>
<input type="text" name="ort" value="<?php echo $ort; ?>" Required>
<input type="text" name="titel" value="<?php echo $titel; ?>" Required>
<input type="text" name="inhalt" value="<?php echo $inhalt; ?>" Required>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="submit" name="update" value="Update">
</form>
Ẁould be really awesome if anyone could help. Thanks is advance!
Maybe you can try using isset function of php to check if that variable contains a value or not for more details check:-https://www.stechies.com/notice-undefined-variable-in-php/
I have a page that loads invoices for clients. I added a date picker to search by date but when the page loads it gives no data until a filter is applied from a form. I want the page to load with all data first then if user wants to filter by date, they can select that.
<form method='post' action='invoices.php' class='sdate'>
<div class="sdate">
<input type="text" name="sdate" placeholder="Start Date" >
</div>
<div class="sdate">
<button type="submit" class="sdatebtn">Submit</button>
</div>
</form>
database query
FROM imw_locations l
INNER JOIN vzw_invoice i
ON l.AddressCode=i.ItemCustomerFullName
WHERE l.owner='" . $owner . " ' AND Txndate='".$sdate."'
Full Data of query
<head>
</head>
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
header('Location: /index.php');
exit();
}
?>
<?php
include "config.php";
$owner = $_SESSION['role'];
$sdate = $_POST['sdate'];
$edate = $_POST['edate'];
?>
<?php include "../../assets/navbar.php" ?>
<div>
<?php echo $sdate;?>
<!---- Date Selections ---->
<form method='post' action='invoices.php' class='sdate'>
<div class="sdate">
<input type="text" name="sdate" placeholder="Start Date">
</div>
<div class="sdate">
<input type="text" name="edate" placeholder="End Date" >
</div>
<div class="sdate">
<button type="submit" class="sdatebtn">Submit</button>
</div>
</form>
<!---- This is the download form ---->
<form method='post' action='../finance/export/download.php'>
<input type='submit' value='Export' name='Export'>
<table class="invoice">
<thead>
<tr>
<th>Reference Number</th>
<th>Memo</th>
<th>Trans. Date</th>
<th>Location</th>
<th>Item Amount</th>
<th>Quantity</th>
<th>Vendor</th>
</tr>
</thead>
<?php
$owner = $_SESSION['role'];
$query = "SELECT l.AddressCode,
l.owner,
l.City,
l.State,
l.Zip,
i.RefNumber,
i.memo,
i.Txndate,
i.DueDate,
i.ItemCustomerFullName,
i.PO_number ,
i.ItemAmount,
i.PO_number,
i.preorder_,
i.Quantity,
i.Vendor,
i.balance
FROM imw_locations l
INNER JOIN vzw_invoice i
ON l.AddressCode=i.ItemCustomerFullName
WHERE l.owner='" . $owner . " '
AND Txndate='".$sdate."'
";
$result = mysqli_query($con,$query);
$user_arr = array();
while($row = mysqli_fetch_array($result)){
$ref = $row['RefNumber'];
$memo = $row['memo'];
$Txndate = $row['Txndate'];
$duedate = $row['DueDate'];
$ItemCustomerFullName = $row['City'];
$PO_number = $row['PO_number'];
$ItemAmount = $row['ItemAmount'];
$preorder_ = $row['preorder_'];
$Quantity = $row['Quantity'];
$Vendor = $row['Vendor'];
$balance = $row['balance'];
?>
<tr>
<td><?php echo $ref; ?></td>
<td><?php echo $memo; ?></td>
<td><?php echo $Txndate; ?></td>
<td><?php echo $ItemCustomerFullName; ?></td>
<td><?php echo $ItemAmount; ?></td>
<td><?php echo $Quantity; ?></td>
<td><?php echo $Vendor; ?></td>
</tr>
<?php
}
?>
</table>
<?php
$serialize_user_arr = serialize($user_arr);
?>
<textarea name='export_data' style='display: none;'><?php echo $serialize_user_arr; ?></textarea>
</form>
</div>
This is tough to answer as the code you posted does not line up with the query you mentioned above it.
The simplest solution would be to set a variable with a string, and append to it if the date is set. This is a simple solution, as you get more conditions, you can make an array and then do an implode on it, but that could be added later. An example:
$whereClause = "WHERE l.owner = '{$owner}'";
if ( ! empty( $sdate) && $sdate ) {
$whereClause .= " AND Txndate = '{$sdate}'";
}
As far as your BETWEEN clause, try switching the dates. I am assuming that $edate is end date and $sdate is start date, and the between clause takes starting date first.
Also, PLEASE read this. You have clear examples of security holes, big ones. You are taking user input and directly injecting it into the DB query. That is a HUGE security hole, and the input needs to be verified and cleaned.
I am having an issue editing mysql database through a html table.
when I run a simple while loop it works, I can pull in the data and update the database:
Working Code
<?php
while ($row = mysqli_fetch_array($res))
echo "$row[id]. $row[Key_Role] .$row[Incumbant] .$row[Attrition_Risk] .$row[Ready_Now] .$row[lowerYears] .$row[higherYears]<a href='edit.php?edit=$row[id]'>edit</a> <br />";
?>
However, when I run the php through a table, the edit links no longer pull in the data from mysql and I am not able to update information. I have put below the index and edit php files.
Index.php
<?php
include_once('db.php');
if(ISSET($_POST['Key_Role']))
{
$Key_Role = $_POST['Key_Role'];
$Incumbant = $_POST['Incumbant'];
$Attrition_Risk = $_POST['Attrition_Risk'];
$Ready_Now = $_POST['Ready_Now'];
$lowerYears = $_POST['1-2_Years'];
$higherYears = $_POST['3-5_Years'];
$sql = "INSERT INTO tmdata VALUES('','$Key_Role','$Incumbant','$Attrition_Risk','$Ready_Now','$lowerYears','$higherYears')";
$res = mysqli_query($conn, $sql);
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
if ($res)
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
else
echo "Failed";
} else {
echo "please enter a key Role";
}
$res = mysqli_query($conn, "SELECT * FROM tmdata");
?>
<style>
<?php include 'style.css' ?>
</style>
<H1 class="Title">Talent Management System</H1>
<form action="." method="post">
Key Role:<input type="text" name="Key_Role">
Incumbant:<input type="text" name="Incumbant">
Attrition_Risk:<input type="text" name="Attrition_Risk">
Ready_Now:<input type="text" name="Ready_Now">
1-2_Years:<input type="text" name="1-2_Years">
3-5_Years:<input type="text" name="3-5_Years">
<input type ="submit" value="Enter">
</form>
<h1> List Of Key Roles</h1>
<?php
/*
while ($row = mysqli_fetch_array($res))
echo "$row[id]. $row[Key_Role] .$row[Incumbant] .$row[Attrition_Risk] .$row[Ready_Now] .$row[lowerYears] .$row[higherYears]<a href='edit.php?edit=$row[id]'>edit</a> <br />";
*/
?>
<table>
<tr>
<th>id</th>
<th>Key_Role</th>
<th>Incumbant</th>
<th>Attrition_Risk</th>
<th>Ready_Now</th>
<th>1-2_Years</th>
<th>3-5_Years</th>
<th>Edit</th>
</tr>
<?php while ($row = mysqli_fetch_array($res)):;?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['Key_Role'];?></td>
<td><?php echo $row['Incumbant'];?></td>
<td><?php echo $row['Attrition_Risk'];?></td>
<td><?php echo $row['Ready_Now'];?></td>
<td><?php echo $row['lowerYears'];?></td>
<td><?php echo $row['higherYears'];?></td>
<td><a href='edit.php?edit=$row["id"]'>edit</a></td>
</tr>
<?php endwhile;?>
</table>
Edit.php
<?php
include_once('db.php');
if (isset($_GET["edit"]))
{
$id = $_GET["edit"];
$res = mysqli_query($conn, "SELECT * FROM tmdata WHERE id='".$id."'");
$row = mysqli_fetch_array($res);
}
if( isset($_POST['newKey_Role']) || isset($_POST['newIncumbant']) || isset($_POST['newAttrition_Risk']) || isset($_POST['newReady_Now']) || isset($_POST['newLowerYears']) || isset($_POST['newHigherYears']) )
{
$newKey_Role = $_POST['newKey_Role'];
$newIncumbant = $_POST['newIncumbant'];
$newAttrition_Risk = $_POST['newAttrition_Risk'];
$newReady_Now = $_POST['newReady_Now'];
$newLowerYears = $_POST['newLowerYears'];
$newHigherYears = $_POST['newHigherYears'];
$id = $_POST['id'];
$sql = "UPDATE tmdata SET Key_Role='$newKey_Role', Incumbant='$newIncumbant', Attrition_Risk='$newAttrition_Risk', Ready_Now='$newReady_Now', lowerYears='$newLowerYears', higherYears='$newHigherYears' WHERE id='".$id."'";
$res = mysqli_query($conn, $sql) or die(mysqli_error($conn));
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
}
?>
<form action="edit.php" method="post">
Key Role:<input type="text" name="newKey_Role" value ="<?php echo $row[1]; ?>"></input> <br />
Incumbant:<input type="text" name="newIncumbant" value ="<?php echo $row[2]; ?>"></input> <br />
Attrition_Risk:<input type="text" name="newAttrition_Risk" value ="<?php echo $row[3]; ?>"></input> <br />
Ready_Now:<input type="text" name="newReady_Now" value ="<?php echo $row[4]; ?>"></input> <br />
1-2 Years:<input type="text" name="newLowerYears" value ="<?php echo $row[5]; ?>"></input> <br />
3-5 Years:<input type="text" name="newHigherYears" value ="<?php echo $row[6]; ?>"></input> <br />
<input type="hidden" name="id" value ="<?php echo $row[0]; ?>">
<input type ="submit" value="Update">
</form>
<style>
<?php include 'style.css' ?>
</style>
It looks as though the ID is not pulling across to the edit php. I also tried manually inputting the id in the table:
<td><a href='edit.php?edit=$row[184]'>edit</a></td>
but this also did not work.
Any help would be very much appreciated.
Thank you in advance.
I figured out that you need to put the link in php.
<td><?php echo "<a href='edit.php?edit=$row[id]'>edit</a>"?></td>
That worked in the end.
I need to Insert data to the DB using the form given below
<form action="OtherEventPayment.php" id="frmSignIn" method="post">
<input type="hidden" name="online_id" value="<?php echo $lid; ?>" >
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Item</th>
<th>No. of Participants</th>
<th>Tick the Items</th>
</tr>
</thead>
<tbody>
<tbody>
<?php
$sn ="1";
$id = $oth_event_id;
$stmt1 = $DB_con->prepare('SELECT * FROM oth_events_details
LEFT JOIN oth_event_category ON (oth_events_details.oth_evcat_id=oth_event_category.oth_evcat_id)
WHERE oth_event_id =:uid ORDER BY oth_event_det_id DESC');
$stmt1->execute(array(':uid'=>$id));
$stmt1->execute();
if($stmt1->rowCount() > 0)
{
while($row1=$stmt1->fetch(PDO::FETCH_ASSOC))
{
extract($row1);
?>
<tr>
<td><?php echo $sn; ?></td>
<td>
<?php echo $row1['oth_category'];?> -
<?php
$group =$row1['oth_catgroup_type'];
if ($group=="S")
{
echo "Single";
}
elseif ($group=="D")
{
echo "Doubles";
}
else{
echo "Group";
}
?>
</td>
<td><?php echo $row1['participntno']; ?></td>
<td>
<b>
</b>
<input type="checkbox" name="chk[<?php echo $row1['oth_event_det_id'];?>]" value="<?php echo $row1['oth_event_det_id'];?>" id="chk[<?php echo $row1['oth_event_det_id'];?>]" />
Fees:- <?php echo $row1['oth_ev_fee'];?>
</td>
</tr>
<?php $sn++; ?>
<?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
</tbody>
</table>
<div class="col-md-6">
<input type="submit" name="selectItems" value="Submit & Proceed" class="btn btn-primary pull-right mb-xl" data-loading-text="Loading...">
</div>
</div>
<?php echo $sn1=$sn-1; ?>
</form>
in the OtherEventPayment.php i have written the code. But not working . How to Insert data correctly to DB
<?php
require_once 'dbconfig.php';
if(isset($_POST['selectItems']))
{
echo array[] = $_POST['chk[]'];
echo $oth_online_id= $_POST['online_id'];
if($oth_event_detid != ""){
for($i=0;$i<sizeof($oth_event_detid);$i++)
{
// oth_event_det_id,oth_online_id
$stmt = $DB_con->prepare('INSERT INTO othevents_itemsonline(oth_event_det_id,oth_online_id) VALUES( :oth_event_det_id, :oth_online_id)');
$stmt->bindParam(':oth_event_det_id',$oth_event_det_id);
$stmt->bindParam(':oth_online_id',$oth_online_id);
if($stmt->execute())
{
$lastonlineid= $DB_con->lastInsertId();
$successMSG = "Thank you For Registering with us . Please select the items to be participating...";
// header("refresh:0;OtherEventsOnlineRegistrationThankyou.php"); /
}
else
{
$errMSG = "error while registering....";
} } }
}
?>
Name should be same for input field. Use following code:
<input type="checkbox" name="chk[]" value="<?php echo $row1['oth_event_det_id'];?>" id="chk[<?php echo $row1['oth_event_det_id'];?>]" />
Fees:- <?php echo $row1['oth_ev_fee'];?>
You can see name. Hopefully it will be clear enough
Just change the value of you checkboxes and the value it represents but keep the name same with the others, yet it should have a name with []
<input type="checkbox" id="chk<?php echo $row1['oth_event_det_id'];?>" name="chk[]" value="<?php echo $row1['oth_event_det_id'];?>">
<label for="chk<?php echo $row1['oth_event_det_id'];?>"><?php echo $row1['oth_event_det_id'];?></label>
having a name chk[] like this will send and serve as an array in your get or post-function so loop it on controller or function that will add it in the DB
upon inserting it,
$data = $_GET['chk']; //this is in array form
foreach($data as $chk){
//insert code here
}
Hopefully someone can help me with this "easy" question.
I have data in a table that has been gathered from a mysql database. I want the user to be able to edit the "PRICE" column to any and all rows, then press the update button which will send the data to the table and update all the rows in the "PRICE" column.
For the life of me I can't get the database to update. I know it has to be something that I'm missing. And it has to be something so easy it's laughable.
Please help?
if (isset($_POST['update']))
{
echo '<pre>';
print_r($_POST);
echo '</pre>';
if (is_array($ID))
{
foreach($_POST['hidden'] AS $ID)
{
echo "ID is: " . $ID . "</br>";
echo "Price is: " . $pricing . "</br>";
$ID = mysqli_real_escape_string($conn, $_POST['hidden'][$ID]);
$pricing = mysqli_real_escape_string($conn, $_POST['price'][$ID]);
$updateQuery = 'UPDATE `bathroom_price` SET `price` ="' . $pricing . '" WHERE `ID`=' . $ID;
mysqli_query($conn, $updateQuery) or die(mysql_error());
}
}
}
?>
</head>
<?php
mysqli_select_db($conn, "table_name");
?>
<div class="row center-xs">
<div style="margin-top:100px;" class="col-xs-12 col-sm-12 col-md-12 col-lg-8">
<div class="box">
<form method=POST>
<h1>Price List for Bathroom Form</h1>
<table>
<?
$secondSQL = "SELECT question, question_ID, ID, form_ID, form_name FROM bathroom_price GROUP BY question_ID, form_name ORDER BY ID ";
$result1 = mysqli_query($conn, $secondSQL);
while ($row = mysqli_fetch_assoc($result1))
{
$question_ID = $row['question_ID'];
$question = $row['question'];
$formID = $row['form_ID'];
$form_name = $row['form_name'];
?>
<input type=hidden value="<? echo $question_ID ?>">
<tr class='questionHeading'>
<td colspan='3'>
<h2><? echo $question ?></h2>
<h3>Questions for the <? echo $form_name ?> Form</h3></td>
</tr>
<tr>
<th>Options:</th>
<th>Price:</th>
<th>Update:</th>
</tr>
<?
$thirdSQL = "SELECT question_ID, options, price, ID FROM bathroom_price WHERE question_ID = $question_ID";
$replies = mysqli_query($conn, $thirdSQL);
while ($rows = mysqli_fetch_assoc($replies))
{
$price = $rows['price'];
$options = $rows['options'];
$ID = $rows['ID'];
?>
<input type=hidden name="hidden[]<?echo $ID ?>" value="<?echo $ID ?>" />
<input type=hidden value="<? echo $question_ID ?> " />
<tr>
<td style='width:60%;'>
<input readonly type=text value="<? echo $options ?>">
</td>
<td style='width:10%;'>
<input type=text name="price[]<?echo $ID ?>" value="<?echo $price ?>">
</td>
</tr>
<?}?>
<?}?>
</table>
<div class="start-xs" style="margin: 0 0 50px 0;">
<button type=submit name="update" class="admin-style" value="Update Price Form">
<i class="fa fa-save"></i> Update Price Form
</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
<?php mysqli_close($conn);?>
Maybe this is a problem:
<input type=hidden name="hidden[]<?echo $ID ?>" value="<?echo $ID ?>" />
Your input name is "hidden[]1" etc.