`Editable-Changable` Variable in a delete statement
think about this with me and tell me if it´s possible:
Lets say u have a simple delete statement like this one:
<?php
$con=mysqli_connect("localhost","root","admin","inventarisdb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (!mysqli_query($con,"DELETE FROM BCD WHERE LastName='Griffin'");
{
echo "Succesfully Deleted <br/> ";
echo "<a href='Reports.php'>View Result</a>";
}
mysqli_close($con);
?>
This statement deletes everything in the table row that matches that given
Lastname. Great! but now:
Lets say that Ur table gets updated a lot and ur adding names and U get
more entries with the same LastName , but U don't want all of them Rows to
get deleted with this LastName.
Is it possible to write the Delete statement in such a way that the
variable for LastName is Editable or Changeable? What I mean is for
example: being able to Change LastName to Age for example or Any other
variable I have in the table that I want to use instead to execute delete
with, without having to do so in my php script, but simply from the app.
page itself.
So the actions u would take with such a code would be navigating to the
Delete tab in this app, Changing the variable u want to use to make ur
search for delete with, through typing or a drop down list for example and
eventually press delete for execute.
I'm thinking something like this for example:
if (!mysqli_query($con,"DELETE FROM persons WHERE (variable)='<a href:
Select2Delete.php>'");
And so I would be able to fill in the variable corresponding to my table
collumns I want to search by to delete.
I have been looking @ checkboxes and auto increment and ways about doing
this differently, but I want to know if this is possible first since I
find it an easy way to make the script work compared to having to set up a
table that first looks up the data and then add checkboxes with a delete
button with a load of If Statements to execute a delete by selecting a box
feel me?
Any advice, comment, remark is welcome! This is a Pure thought that I want
to share and ask ur opinion about!
Thank you in advanced! Cheers to this forum!
No comments:
Post a Comment