Update and Delete button for each item of a database table using php and javascript -
i can show items of table in database , create delete , update button. want when press delete button of item, id of item , delete database not right , can not find it. when press delete button of item nothing happens. here code:
php file:
<body> <?php $con = mysql_connect("localhost:3307", "root", ""); mysql_select_db("seiis_notes", $con); $result = mysql_query("select * tbl_notes"); ?> <table> <?php while($row = mysql_fetch_array($result)) { ?> <div class="note_and_btns"> <div class="notedescription_editnote"> <form action="updateordelete.php" method="post"> id: <input type="text" name="id" value="<?php echo $row["noteid"] ?>" readonly/> <br/> description: <input type="text" name="projects" value="<?php echo $row["rel_projects"] ?>" readonly/> <br/> creator: <input type="text" name="creator" value="<?php echo $row["note_creator"] ?>" readonly/> <br/> <input id="<?php echo $row["noteid"] ?>" name="action" type="submit" value="edit"/> <input id="<?php echo $row["noteid"] ?>" name="action" type="submit" value="delete"/> </form> </div> </div> <br/> <br/> <?php } ?> <br/><br/>
and here update or delete file:
<body> <?php $con = mysql_connect("localhost:3307", "root", ""); mysql_select_db("seiis_notes", $con); if ($_post['action'] == 'delete') { $value = $_post["id"]; mysqli_query($con, "delete tbl_notes id='$value'"); echo "<script type='text/javascript'>alert('deleted succesfully');</script>"; ?> <meta http-equiv="refresh" content="5;url=notes.html"/> <?php } else if ($_post['action'] == 'edit') { //code edit data } ?> </body>
Comments
Post a Comment