本文目錄一覽:
php中怎麼來執行一個按鈕事件
可以在按鈕裡面加一個單擊事件,然后里面加一個帶參數的鏈接地址。
input type=”buttom” onclick=”javascript:window.location.href=’post.php?sub=yes'”
單擊之後,執行鏈接,然後php代碼就可以這麼寫:
?php
if($_GET[‘sub’] == ‘yes’)
{
執行的代碼,省略…..
}
?
php 頁面上一個按鈕,如何點擊後觸發相關事件,著急。
?php
if(!empty($_POST[‘chaxun’])){ //點擊提交按鈕後才執行
$sql = “select * from 資料庫表名 where 條件”;//從資料庫中查詢數據
$query = mysql_query($sql);
$row = mysql_fetch_assoc($query);//數據結果集
}
?
table
tr?php echo $row[‘欄位名1’];?/tr
tr?php echo $row[‘欄位名2’];?/tr
tr?php echo $row[‘欄位名3’];?/tr
……
/table
form action=”” method=”post”
input type=”heddin” name=”chaxun” value=”查詢數據隱藏域” /
input type=”submit” name=”button” value=”提交” /
/form
php中怎麼觸發按鈕事件
點按鈕後提交表單,服務端判斷有無提交表單
?php
if (isset($_REQUEST[*is_submit*]) $_REQUEST[*is_submit*])
{
//你要完成的工作
}
?
form method=”post” action=””
input type=”submit”
input type=”hidden” name=”is_submit” value=”1″
/form
php 怎麼自動觸發 事件
php是沒有onclick的你可以用js來驅動如:setTimeout(‘location.href=”aaa.php”,2000’);也就是2秒鐘後再次載入aaa.php
PHP按鈕事件
?php
$file = ‘1.txt’;
$searchfor = ‘尋找的內容’;
// the following line prevents the browser from parsing this as HTML.
header(‘Content-Type: text/plain’);
// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($file);
// escape special characters in the query
$pattern = preg_quote($searchfor, ‘/’);
// finalise the regular expression, matching the whole line
$pattern = “/^.*$pattern.*\$/m”;
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
echo “有”;
}
else{
echo “沒有”;
}
原創文章,作者:XQAML,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/325379.html