Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

[php] delete row with a <button>

guys im wonder how can i create some button that delete data from a table i didn't find how could i do it so i have replaced the button with <a> tag ==><a href="edit.php?id= . $$row["name"] for the where condition delete from list where id = '$_GET['name']'
[Image: T31URyT.png]
index.php file
PHP Code

<?php 
$conn 
= mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
 
 die("Connection failed: " . mysqli_connect_error());
}

 
 $sql = "DELETE FROM list where name = '$id'";


if (
mysqli_query($conn, $sql)) {


 
 echo "succes delete you can back <a href='index.php' back </a>";

 
 
} else {
 
 echo "_error_: " . $sql . "<br>" . mysqli_error($conn);
} 

updatetable.php file
PHP Code

<?php 
 while
($row = mysqli_fetch_assoc($result)) {
 
   echo "<tr><td>"."<a href='php/updatetable.php?id=" . $row["name"]. " </a></td><td> " . $row["description"]. "</td><td> " . $row["matiere"]. "</td><td>".$row["date"]."</td><td>".$row["jour"]."</td><td>".$row["time"]."</td></tr></form>";
 
 }
} else {
 
 echo "0 results";
}
echo
"</tbody></table></div>";

?>
Writeln('Give me a Target >');
[Image: giphy.gif]
delete the row in the db and load the table again
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
i want to create a buttuon to select a specific item to delete it in the table
Writeln('Give me a Target >');
[Image: giphy.gif]
so add button and onclick put the code to delete it and load the table again
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Jun 8, 2020 01:20 PM)HFDone Wrote:  so add button and onclick put the code to delete it and load the table again

can you show me some example please
Writeln('Give me a Target >');
[Image: giphy.gif]
search for html table delete row by id
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
https://stackoverflow.com/questions/2906...ike-a-link
You see, Doctor, God didn't kill that little girl. Fate didn't butcher her and destiny didn't feed her to those dogs.
If God saw what any of us did that night he didn't seem to mind. From then on I knew... God doesn't make the world this way.
We do.
(Jun 9, 2020 04:46 AM)Squito Wrote:  https://stackoverflow.com/questions/2906...ike-a-link

dude i want to create a button that delete a specific row from database like the example in the picture
Writeln('Give me a Target >');
[Image: giphy.gif]
And I provided a solution, that you have to change slightly to work the way you want it. If I do it all for you, you are going to miss the 'figuring out' part of the process, which is eventually a bad thing.
You see, Doctor, God didn't kill that little girl. Fate didn't butcher her and destiny didn't feed her to those dogs.
If God saw what any of us did that night he didn't seem to mind. From then on I knew... God doesn't make the world this way.
We do.
https://stackoverflow.com/a/46325093
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Jun 9, 2020 08:16 AM)Squito Wrote:  And I provided a solution, that you have to change slightly to work the way you want it. If I do it all for you, you are going to miss the 'figuring out' part of the process, which is eventually a bad thing.

thank you alot dude i will try it <3
Writeln('Give me a Target >');
[Image: giphy.gif]
I do it like this.
On table:
Code
- loop on result
- get the row id
- placed the row id on a href link of delete button

Example: <a href="?action=delete&id=ROW_ID">Delete</a>

On back-end code:
Code
- Check for the action and id query param
- Do the delete query using the id query param
(Jun 9, 2020 07:39 PM)Backbone Wrote:  I do it like this.
On table:
Code
- loop on result
- get the row id
- placed the row id on a href link of delete button

Example: <a href="?action=delete&id=ROW_ID">Delete</a>

On back-end code:
Code
- Check for the action and id query param
- Do the delete query using the id query param

your idea is pretty good thank you aloot
Writeln('Give me a Target >');
[Image: giphy.gif]
(Jun 10, 2020 10:26 AM)blackcoder00 Wrote:  your idea is pretty good thank you aloot

friendly reminder to use prepared statement for this


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by dawid17Jun 4, 2020 06:22 AM 0 99 Jun 4, 2020 06:22 AM
Last Post: dawid17
[PHP] by Zan0nJun 30, 2019 10:28 AM 1 143 Jun 30, 2019 10:28 AM
Last Post: Nachfolger
[PHP] by JASJan 14, 2018 11:52 AM 2 162 Jan 14, 2018 11:52 AM
Last Post: RumbleFrog