How to implement search by entering at least one content in multiple Search boxes

Source: Internet
Author: User
Tags mysql manual
Response & lt; html & gt; & lt; head & gt; & nbsp; & lt; title & gt; AnewApplicationforaclassroom & lt;/title & gt; & lt; /How to implement search by entering at least one content in multiple search boxes
Apply.html


A new Application for a classroom



CRMS-New classroom Entry





2. php



A new Application for a classroom


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 ","");
// Establish a connection through the server locahost. the user name is root and no password is required.

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



The reason is that the Classroom ID or Course ID cannot be successfully searched. I have written if (! $ Cno) {$ Cno = "% ";}
If (! $ CID) {$ CID = "%";} if it is not specified, use the wildcard character and the LIKE character is used during the query. (if all the LIKE characters in the query are replaced with = characters, the query is successful ). Why? Online, etc!

------ Solution --------------------
Because you use like. Check the mysql manual.

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.