php - Updating a row on an Admin Page -


i trying create admin page pull rows table , allow "admin" make changes. while can figure out code. suggest me how can display row data , make editable , saveable database. if "admin" needs update artist name, how manage keeping other data intact. don't know how done.

the update page 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 painting</h2> <hr>  <div> <h1>search painting name :</h1> <form name="searchbypainting" action="editpainting.php" method="post"> <input list="paintings" name="frompaintings"> <datalist id="paintings"> <?php //insert query extract artist names form database $result = mysqli_query($con,'select `artname` 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 extract row painting name $result = mysqli_query($con,"select * paintings `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 : id int(11) | artname tinytext | artdescription text | artistname tinytext | artistdescription text | price bigint(11) | filename varchar(5555)

to make data editable type following code (put row value html inputs)

<input name="artname" type="text" size="32" value="<?=$row['artname']?>"> <input accept="artistname" type="text" size="32" value="<?=$row['artistname']?>"> <input name="price" type="text" size="32" value="<?=$row['price']?>"> <input name="filename" type="text" size="32" value="<?=$row['filename']?>"> 

for update fields should send them using html form

<form action="editpainting-save.php" method="post" enctype="multipart/form-data">   <input ...>  <input ...> </form> 

to editpainting-save.php following command

<? $update_query="update paintings set     artname='".$_post['artname']."',     artname='".$_post['artname']."',     artname='".$_post['artname']."',     artname='".$_post['artname']."'     limit 1"; $mysqli->query($update_query); ?> 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -