我想在点击按钮时包含一个功能。代码基本上从数据库中检索数据行,每行都有一个X按钮。我希望我的解释清楚!
( "</td><td><a href ='delete.php?id=".
$row['trade_id']."'>X</a>
</td></tr>"; )
。如何在点击ahref X时执行操作(包含函数)?我该怎么做呢?例如:
if (buttonclicked)
{
require 'function.php';
}
腓
while($row = mysql_fetch_assoc($result)){
echo "<tr><td>" . $row['trade_id'] .
"</td><td>" . $row['selection'] .
"</td><td>" . $row['date'] .
"</td><td>" . $row['type'] .
"</td><td>" . $row['size'] .
"</td><td>" . $row['bidprice'] .
"</td><td>" . $row['offerprice'] .
"</td><td>" . $row['stoploss'] .
"</td><td>" . $row['takeprofit'] .
"</td><td>" . $closedb .
"</td><td>" . $profit .
"</td><td><a href ='delete.php?id=".
$row['trade_id']."'>X</a>
</td></tr>";
echo "</table><br>";
答案 0 :(得分:0)
delete.php
if(isset($_GET["id"])){
require 'function.php';
}
答案 1 :(得分:0)
if(isset($_GET['id'])) { //Equals your "button clicked."
$id = intval($_GET['id']); //Thats the ID you provided through "?id=1234".
require 'function.php';
}
答案 2 :(得分:0)
:
if(isset($_GET['id']) && $_GET['id'] != null && $_GET['id'] != ""){
require_once 'function.php';
$myFunction = new myFunctionClass();
$myFunction->DoMyDeleteLogic($_GET['id']); // protect data from get before
//or static class
MyFunctionClass::DoMyDeleteLogic($_GET['id']);
}
else{
echo('datas missing...'); //put a throw exception
}