开发者

calling php function to delete a record from database doesn't work

can you please have a look at these codes and let me know why mysql query doesn't work?

in a php file I add a check box to my page with following code

echo "<input type=checkbox name=box[] onClick=\"deleteLink('$ClickedWord','$rLinks');\"'>";

then in another php file "deleteLink" function exists and its code is:

function deleteLink($clword,$DltLinks)
{

<?php
      session_start(); // start up your PHP session!
      $u= $_SESSION['Unit'];
      $f= $_SESSION['file'];
      mysql_query("DEL开发者_StackOverflow中文版ETE FROM links WHERE ((Unit_Code='$u') && (File_Name='$f')&& (Word='$clword')&& (Link_Add='$DltLinks'))") or die(mysql_error());
?>
}

I am sure that this file executes but doesn't delete the record. I did some tests to find the problem but no result!!!


I think you're missing something here. I'm pretty sure you can't directly call a php function with an onClick handler. You'd have to write a javascript function that creates and AJAX request to pass the values to the php page with the function.

I think the reason that you think it's being called is that you're actually calling it as you're creating the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜