<?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