Execute php sql stmt from php echo within <img> tag

I have a php echo statement with an tag within.

[php]echo “


the link that the img tag points to is the same page orders.php. What i’d like to do is when the user clicks the image, a php sql statement should be executed to delete that particular record from the database and also refresh the same page orders.php. Am not sure where to place the sql statement? Please advise.

You can either use ajax (which I’m guessing you do not know) or put it in a form tag and give it a value


"; [/php]

Then in orders.php at the top put…

<?php if(isset($_POST['delete'])){ $sql = mysql_query("DELETE FROM yourTableName WHERE value= '".$_POST['delete']."'"); if($sql){ echo "Success"; } else { echo "Fail"; } } ?>


Does that help you?



could you please clarify what the value tag above should hold?

Is should ideally contain the Primary Key of that item from the db.

Sponsor our Newsletter | Privacy Policy | Terms of Service