Find a house (Database Application), find a house database application

Source: Internet
Author: User

Find a house (Database Application), find a house database application

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
</Head>

<Body>

<H1> house rental
<Form action = "zufangzi. php" method = "post">
<Div> region: <input type = "checkbox" name = "qx" onclick = "quanxuan (this, 'qy')"/> select all </div>
<Div>
<? Php
Require "../0428/DBDA. class. php ";
$ Db = new DBDA ();

$ Sqy = "select distinct area from housedb ";
$ Aqy = $ db-> query ($ sqy );
Foreach ($ aqy as $ v)
{
Echo "<input type = 'checkbox' name = 'qy [] 'value = '{$ v [0]}' class = 'qy'/> {$ v [0] }";
}
?>
</Div>
<Br/>

<Div> Lease type: <input type = "checkbox" name = "zlqx" onclick = "quanxuan (this, 'zl')"/> select all </div>
<Div>
<? Php
$ Szl = "select distinct type from housedb ";
$ Azl = $ db-> query ($ szl );
Foreach ($ azl as $ v)
{
Echo "<input type = 'checkbox' name = 'zl [] 'value = '{$ v [0]}' class = 'zl'/> {$ v [0] }";
}
?>
</Div>
<Br/>
<Div> housing type: <input type = "checkbox" name = "fwqx" onclick = "quanxuan (this, 'FW ')"/> select all </div>
<Div>
<? Php
$ Sfw = "select distinct housetype from housedb ";
$ Afw = $ db-> query ($ sfw );
Foreach ($ afw as $ v)
{
Echo "<input type = 'checkbox' name = 'FW [] 'value = '{$ v [0]}' class = 'FW '/> {$ v [0] }";
}
?>
</Div>
<Br/>
<Div> Keyword: <input type = "text" name = "key"/> <input type = "submit" value = "query"/> </div>
</Form>
<Br/>

<Table width = "100%" border = "1" cellpadding = "0" cellspacing = "0">
<Tr>
<Td> keywords </td>
<Td> region </td>
<Td> building area </td>
<Td> rent </td>
<Td> Lease Type </td>
<Td> house type </td>
</Tr>
<? Php

$ Tj1 = "1 = 1 ";
$ Tj2 = "1 = 1 ";
$ Tj3 = "1 = 1 ";
$ Tj4 = "1 = 1 ";

If (! Empty ($ _ POST ["qy"])
{
$ Aqy = $ _ POST ["qy"];
$ Sqy = implode ("','", $ aqy );

$ Tj1 = "area in ('{$ sqy }')";
}

If (! Empty ($ _ POST ["zl"])
{
$ Azl = $ _ POST ["zl"];
$ Szl = implode ("','", $ azl );

$ Tj2 = "primitive type in ('{$ szl }')";
}

If (! Empty ($ _ POST ["fw"])
{
$ Afw = $ _ POST ["fw"];
$ Sfw = implode ("','", $ afw );

$ Tj3 = "housetype in ('{$ sfw }')";
}

If (! Empty ($ _ POST ["key"])
{
$ K = $ _ POST ["key"];
$ Tj4 = "keyword like '% {$ k} % '";
}


$ SQL = "select * from housedb where {$ tj1} and {$ tj2} and {$ tj3} and {$ tj4 }";
Echo $ SQL;

$ Arr = $ db-> query ($ SQL );
Foreach ($ arr as $ v)
{
Echo "<tr>
<Td >{$ v [1]} </td>
<Td >{$ v [2]} </td>
<Td >{$ v [3]} </td>
<Td >{$ v [4]} </td>
<Td >{$ v [5]} </td>
<Td >{$ v [6]} </td>
</Tr> ";
}
?>
</Table>

</Body>
<Script type = "text/javascript">
Function quanxuan (qx,)
{
// Find the checkbox list corresponding to the Select All button
Var ck = document. getElementsByClassName ();
// Select the status of the Select All button
If (qx. checked)
{
For (var I = 0; I <ck. length; I ++)
{
Ck [I]. setAttribute ("checked", "checked ");
}
}
Else
{
For (var I = 0; I <ck. length; I ++)
{
Ck [I]. removeAttribute ("checked ");
}
}

}
</Script>
</Html>

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.