-3
當前,當用戶登錄時,查詢自動運行並將數據打印到屏幕上。但是,我希望屏幕在初始登錄時爲空白。PHP MySQL清除查詢
這是我的PHP函數調用數據:
<?php
function displayrecords() {
$groups = $_POST['mygroup'];
$type = $_POST['mytype'];
$service = $_POST['myservice'];
$sql_json = "SELECT * FROM mytable";
$where = "";
if ($groups != "") {
$where = " `mygroup` = '" . mysql_real_escape_string($groups) . "'";
}
if ($type != "") {
if ($where != "")
$where .= " AND ";
$where .= " `mytype` = '" . mysql_real_escape_string($type) . "'";
}
if ($service != "") {
if ($where != "")
$where .= " AND ";
$where .= " `myservice` = '" . mysql_real_escape_string($service) . "'";
}
if ($where != "")
$sql_json = $sql_json . " WHERE " . $where . ";";
$QueryResult = @mysql_query($sql_json) or die(mysql_error());
echo "<table class='table table-striped table-bordered table-hover'>\n";
echo "<tr><th>ID</th>" . "<th>Group</th><th>Type</th>" .
"<th>Service</th>" . "<th>Description</th></tr>\n";
while (($Row = mysql_fetch_assoc($QueryResult)) !== FALSE) {
echo "<tr><td>{$Row[pk_tId]}</td>";
echo "<td>{$Row[mygroup]}</td>";
echo "<td>{$Row[mytype]}</td>";
echo "<td>{$Row[myservice]}</td>";
echo "<td>{$Row[mydescription]}</td>
</tr>\n";
};
echo "</table>\n";
if (mysql_num_rows($QueryResult) == 0) {
echo "No results";
}
}
?>
我需要添加等什麼,這個查詢不會在初始登錄執行?另外,我將如何添加重置按鈕?
預先感謝您。
你需要更精確的提出你的問題。您可以輕鬆地不調用該函數,它永遠不會執行,從而使初始登錄屏幕變爲空白。 – jkushner
試着把''死亡''在你的功能開始處 – NDM
嘗試死亡;但該功能在之後不再有效。必須有一些類似的php代碼:if(login == initialLogin){不要調用函數};或者其他的東西。 – HoodCoderMan