How to put a working "delete" button on my html page | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to put a working "delete" button on my html page

I am having a difficulty time in this problem. Can anyone help me around this stuff? I really need your help

11th Mar 2017, 3:43 PM
Rossel Jay Pajo
Rossel Jay Pajo - avatar
6 Answers
+ 1
you want to put a delete button, for what specifically?
11th Mar 2017, 3:44 PM
Welliton Malta
Welliton Malta - avatar
+ 1
you create a simple button by <input type="submit" .... > then update the database based on the button. e.g: you press the button and by that the data-base updates by deleting the content. As you inserted data in the data base with register form you can also delete it.
11th Mar 2017, 3:55 PM
David
David - avatar
0
I am making this web app about Job Board which registers jobs. After getting registered, I want to put a delete button so that if the user wants to delete the registered job, it can be deleted
11th Mar 2017, 3:47 PM
Rossel Jay Pajo
Rossel Jay Pajo - avatar
0
is it on soloLearn? can you show me your code if it is? just inserting an input button with no events attatched won't work
11th Mar 2017, 3:51 PM
Welliton Malta
Welliton Malta - avatar
0
I wasn't making the code in soloLearn. I'm making it on my pc
11th Mar 2017, 3:53 PM
Rossel Jay Pajo
Rossel Jay Pajo - avatar
0
I can see there has been alot of answers, but this you would use the <input type="button" value="submit"/>Delete Job</input> The reason is that your asking the code to "submit" and do what your telling it. So when it submits the information you will have another page or script that fetches the data or "deletes" the data from mysql (I take its where you store the information) Below is a PHP Example, and its not meeting security standards but you will get the idea why we use submit and how it would work. <?php //index.php include('connection.php'); $result = mysql_query("SELECT * FROM orderform"); echo "<table border='1' > <tr> <th><u>ID</th> <th><u>Date</th> <th><u>Product</th> <th><u>Product Comments</th> <th><u>Name</th> <th><u>Address</th> <th><u>Age</th> <th><u>Delivery</th> <th><u>Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id']. "</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['product'] . "</td>"; echo "<td>" . $row['productcomments'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['address'] . "</td>"; echo "<td>" . $row['age'] . "</td>"; echo "<td>" . $row['delivery'] . "</td>"; echo "<td><a href=\"delete.php?id=".$row['id']."\">delete</a></td>"; echo "</tr>"; } echo "</table>"; ?> <?php //delete.php include('connection.php'); $id = $_GET['id']; //this needs to be sanitized if(!empty($id)){ $result = mysql_query("DELETE FROM orderform WHERE id=".$id.";"); } header("Location: index.php"); ?> So it gets info from index.php it "submits" it to the database and deletes the rows that it was requested. Hope it helps :)
11th Mar 2017, 5:06 PM
Simen Daehlin
Simen Daehlin - avatar