<?php
$con=mysqli_connect("localhost","root","","ok_db")or die(mysqli_connect_error());
$output = 'arslan';
// collect
if (isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysqli_query($con,"SELECT * FROM user_data WHERE fname LIKE '%$searchq%'") or die("Could not search.");
$count = mysqli_num_rows($query);
if($count == 0) {
$output = 'No results found.';
} else {
while($row = mysqli_fetch_array($query)) {
$itemname = $row['fname'];
$description = $row['lname'];
$image = $row['id'];
$output .= '<div>'.$itemname.' '.$description.'</div>';
}
}
}
else{
echo "no" ;
}
?>
<html>
<head>
<title>searching</title>
</head>
<body>
<form action="search.php" method="POST">
<input type="text" name="search" placeholder="Search">
<input type="submit" value=">>" />
</form>
</body>
<?php
print $output;
?>
</html>
此代碼在我的本地主機(XAMPP)上正常工作,但沒有在PhpStorm中回顯任何內容,isset
函數在那裏不工作,並始終顯示輸出「no」。PhpStorm isset函數不工作?
我的PhpStorm設置有問題,因爲它在localhost
上運行正常?
當你說phpstorm不顯示任何東西,你的意思是你使用'在瀏覽器中查看'選項?如果你只是在本地加載文件,並不會呈現任何PHP,因爲它沒有服務器可以通過。 – DevDonkey
您必須使用PhpStorm自己的內置簡單Web服務器..哪個ATM在處理POST請求時遇到問題。只需配置PhpStorm即可使用XAMPP安裝中的Apache - http://stackoverflow.com/a/34787827/783119。當這不起作用時,瀏覽器地址欄中顯示的URL是什麼? – LazyOne
順便說一句 - 在技術上'isset'不是一個函數,但語言結構的行爲像函數 – LazyOne