How to edit other fields?
How to edit other fields?
CREATE TABLE `tbl_image` ( `tbl_image_id` INT(11) NOT NULL, `first_name` VARCHAR(100) NOT NULL, `last_name` VARCHAR(100) NOT NULL, `image_location` VARCHAR(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
<?php $conn = new PDO('mysql:host=localhost; dbname=upload_image','root', ''); ?>
<!-- Modal --> <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> </div> <div class="modal-body"> <form method="post" action="upload.php" enctype="multipart/form-data"> <table class="table1"> <tr> </tr> <tr> </tr> <tr> </tr> </table> </div> <div class="modal-footer"> </div> </form> </div>
<?php require_once ('db.php'); // echo ""; // }else{ // $file=$_FILES['image']['tmp_name']; // $image = $_FILES["image"] ["name"]; // $image_name= addslashes($_FILES['image']['name']); // $size = $_FILES["image"] ["size"]; // $error = $_FILES["image"] ["error"]; // // if ($error > 0){ // die("Error uploading file! Code $error."); // }else{ // if($size > 10000000) //conditions for the file // { // die("Format is not allowed or file size is too big!"); // } // // else // { $location=$_FILES["image"]["name"]; $fname=$_POST['first_name']; $lname=$_POST['last_name']; $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "INSERT INTO tbl_image (first_name, last_name, image_location) VALUES ('$fname', '$lname', '$location')"; echo "<script>alert('Successfully Added!!!'); window.location='index.php'</script>"; // } } // } ?>
<!-- Modal Update Image --> <div id="updte_img<?php echo $id;?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> </div> <div class="modal-body"> <div class="alert alert-danger"> <?php if($row['image_location'] != ""): ?> <img src="uploads/<?php echo $row['image_location']; ?>" width="100px" height="100px" style="border:1px solid #333333; margin-left: 30px;"> <?php else: ?> <img src="images/default.png" width="100px" height="100px" style="border:1px solid #333333; margin-left: 30px;"> <?php endif; ?> <form action="edit_PDO.php<?php echo '?tbl_image_id='.$id; ?>" method="post" enctype="multipart/form-data"> <div style="color:blue; margin-left:150px; font-size:30px;"> <input type="file" name="image" style="margin-top:-115px;"> </div> </div> <hr> <div class="modal-footer"> </form> </div> </div> </div>
<?php require_once ('db.php'); $get_id=$_REQUEST['tbl_image_id']; $location1=$_FILES["image"]["name"]; $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "UPDATE tbl_image SET image_location ='$location1' WHERE tbl_image_id = '$get_id' "; echo "<script>alert('Successfully Updated!!!'); window.location='index.php'</script>"; ?>
<!-- Modal Deleting Image --> <div id="delete<?php echo $id;?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> </div> <div class="modal-body"> <div class="alert alert-danger"> <?php if($row['image_location'] != ""): ?> <img src="uploads/<?php echo $row['image_location']; ?>" width="100px" height="100px" style="border:1px solid #333333;"> <?php else: ?> <img src="images/default.png" width="100px" height="100px" style="border:1px solid #333333; margin-left:15px;"> <?php endif; ?> <br /> </div> <hr> <div class="modal-footer"> </div> </div> </div>
<?php require_once('db.php'); $get_id=$_GET['tbl_image_id']; // sql to delete a record $sql = "Delete from tbl_image where tbl_image_id = '$get_id'"; // use exec() because no results are returned ?>
How to edit other fields?