用函数映射链接
假设我有一个链接和一个函数,如下所示,如何将此链接与该函数映射?
结果,用户点击链接“remove user”将执行函数“remove_user”
<a href="xxx">remove all compare items</a>
functio remove_user() {
return mysql_query("DELETE * FROM compre_items");
}
Suppose I have a link and a function as below, how can I map this link with the function?
As a result, user click on the link "remove user" will execute the function "remove_user
<a href="xxx">remove all compare items</a>
functio remove_user() {
return mysql_query("DELETE * FROM compre_items");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你将不得不做这样的事情:
但这不是开发 Web 应用程序的良好模式/风格。
查看MVC 模式来分离业务和演示逻辑。与 Zend Framework、Cake PHP 或其他 MVC 框架相比。
You will have to do something like this:
But this is not good pattern/style to develop web applications.
Check out MVC pattern to separate business and presentation logic. Than MVC frameworks like Zend Framework, Cake PHP or others.
有很多方法可以做到这一点,但这里有一个简单的建议:
创建functions.php(或任何你想调用它的名称)并将remove_user()函数放入其中,然后添加以下逻辑:
你可能想要添加一些东西这告诉函数要删除哪个用户......
There are many ways to do this, but here is a simple suggestion:
Create functions.php (or whatever you want to call it) and put your remove_user() function inside, then add this logic:
You'll probably want to add something that tells the function which user to remove though ...
我建议你使用 jQuery Ajax :
// --------- html 文件
I suggest you use jQuery Ajax :
// --------- html File