将PHP函数放入按钮
如何将此功能放入按钮中?它需要在我单击按钮时显示将PHP函数放入按钮,php,Php,如何将此功能放入按钮中?它需要在我单击按钮时显示 public function index() { $student_applied_tbl = $this->create_table([ //tbl_id "tbl_id" => "tbl_student_applied", //column headers name address type and button he
public function index()
{
$student_applied_tbl = $this->create_table([
//tbl_id
"tbl_id" => "tbl_student_applied",
//column headers name address type and button headers
"tbl_headers" => ["Student_Name","Service Name","Status",""],
"tbl_rows" => []
], true, base_url("index.php/dashboard/get_applied"));
将该功能放入按钮中?你的意思是当你点击按钮时执行这个功能 下面是如何使用PHP、JavaScript/jQuery和AJAX实现这一点: 或者,您可以将PHP用于:
PHP是一种服务器端语言,您不能在按钮上放置函数,但您可以让按钮将您带到一个页面,在该页面中,PHP将在按钮端类型onclick=dosomecall中执行;在dosomecall中,使用带有一些数据值的ajaxpost,如果isset[$\u post['data']]调用php函数。
<input type="submit" name="run-function-button" id="run-function-button" value="Execute Function">
<script>
$('#run-function-button').click(function() {
$.ajax({
type: "POST",
url: "your-file.php",
data: {
name: "run-function"
}
});
});
</script>
<?php
if (isset($_POST['name'])) {
index();
}
?>
<form action="your-file.php" method="post">
<input type="submit" name="run-function-button" id="run-function-button" value="Execute Function">
</form>
<?php
if (isset($_POST['name'])) {
index();
}
?>