I am trying to create an Admin page which will pull up rows from a table and allow the "admin" to make changes. While I can figure out the code. I would like you to suggest me how can I display the row data and make it editable and saveable to the database. If the "admin" needs to update only the Artist Name, how do I manage that keeping the other data intact. I just don't know how to get this done.
The Update page so far :
<?php
//creating MySQL connection
$con=mysqli_connect('localhost','SouravBasuRoy','2525','MyteraArt');
//
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="admin-styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Admin Panel: Paintings | Mytera Art</h1>
<h2>Update a Painting</h2>
<hr>
<div>
<h1>Search by Painting Name :</h1>
<form name="SearchByPainting" action="editpainting.php" method="post">
<input list="paintings" name="frompaintings">
<datalist id="paintings">
<?php
//Insert Query to extract Artist names form Database
$result = mysqli_query($con,'SELECT `ArtName` FROM Paintings');
while($row = mysqli_fetch_array($result))
{
echo '<option value="' . $row['ArtName'] . '">' ;
}
?>
</datalist>
<input type="submit">
</form>
</div>
<!-- Display Area -->
<div>
<?php
if(isset($_POST['frompaintings']))
{
$item = $_POST['frompaintings'] ;
//MySQL Query to extract row by Painting Name
$result = mysqli_query($con,"SELECT * FROM Paintings WHERE `ArtName` = '$item'");
while($row = mysqli_fetch_array($result))
{
echo '<p>' . $row['ArtName'] . '</p>' ;
echo '<p>' . $row['ArtistName'] . '</p>' ;
echo '<p>' . $row['Price'] . '</p>' ;
echo '<p>' . $row['FileName'] . '</p>' ;
echo '' ;
}
}
?>
</div>
</body>
</html>
The table structure is : ID int(11) | ArtName tinytext | ArtDescription text | ArtistName tinytext | ArtistDescription text | Price bigint(11) | FileName varchar(5555)