My delete button:
$('#taglist li #delete').bind('click', function(){
pic_id = $(this).parent().attr("rel");
$.post('savetag.php', {"type":"remove", pic_id:pic_id}, function(data){
viewtag();
});
});
savetag.php
if ($_POST['type'] == "remove")
{
$pic_id = $_POST['pic_id'];
$sql = "DELETE FROM image_tag WHERE `pic_id` = $pic_id";
mysql_query($sql);
}
Here is the script that views the tags, viewtag.php:
$sql = "SELECT * FROM image_tag ORDER BY `pic_id`";
$qry = mysql_query($sql);
$rs = mysql_fetch_array($qry);
if ($rs){
do{
echo '<li rel="'.$rs['pic_id'].'"><a>'.$rs['name'].'</a> <a class = "delete">Delete</a></li>';
}while($rs = mysql_fetch_array($qry));
}
Here is the function that allows viewtag.php into my index.php:
viewtag();
function viewtag()
{
$.post('viewtag.php', function(data){
$('#taglist ol').html(data);
});
}
So what is the problem, why is it not deleting the table? Also the anchor tag isn't working (anchor tag which is echoed from viewtag.php). What is the problem? Thanks.
echo "hi";before$pic_idin yoursavetag.phpand checkout.