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

I have a php echo statement with an tag within.

[php]echo “

delete”[/php]

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]
echo"

"; [/php]

Then in orders.php at the top put…
[php]

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

[/php]

Does that help you?

[php]echo"

";[/php]

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