How to implement multiple find boxes just fill in at least one find content to find

Source: Internet
Author: User
Tags mysql manual
How to implement multiple find boxes just fill in at least one find content to find
Apply.html


<title>A new application for a classroom</title>



Crms-new Classroom Entry







2.php



<title>A new application for a classroom</title>


Crms-new Classroom Entry Results


Create short variable names
$Cno =$_post[' Cno '];
$CID =$_post[' CID '];

if (! $Cno) {$Cno = "%";}
if (! $CID) {$CID = "%";}

if (!GET_MAGIC_QUOTES_GPC ()) {
$Cno = Addslashes ($Cno);
$CID = Addslashes ($CID);
}

$con = mysql_connect ("localhost", "root", "");
Connect via server locahost, user name is root, no password

if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("CRMs", $con);

$search _classroom = "SELECT * FROM Use2
WHERE Cno like ' {$Cno} ' and CID like $CID ";
$result = mysql_query ($search _classroom, $con);

while ($row = Mysql_fetch_array ($result))
{
echo $row [' Cno '];
echo $row [' CID '];
echo "
";
}
Mysql_close ($con)
?>



Why this cannot be achieved when the classroom ID or course ID is not filled out, still can successfully search. I have already written if (! $Cno) {$Cno = "%";}
if (! $CID) {$CID = "%";} If you do not fill in the wildcard character, and the query is also used like (if the query as if all to = is successful). Why? Online and so on!

------Solution--------------------
Because you use like. Check out the MySQL manual.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.