Value is coming through from form submission.
if(isset($_POST['Submit']))
{
$name=$_POST["Name"];
}
?>
Does not use if statement. Whether $name is empty or not, always adds where clause.
<?php
$sql = "SELECT * FROM dirCsv_500" ?>
<?php if (!empty($name)) {
" where name like '%".$name."%'";
} ?>
you can do it like this:
if(isset($_POST['Name']))
{
$name=$_POST["Name"];
// do what you need with given $name
//and then:
sql = "SELECT * FROM dirCsv_500 WHERE name LIKE '%".$name."%'";
}
else
{
sql = "SELECT * FROM dirCsv_500";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.