赶集网网站建设,做外贸 网站,陈铭生怎么死的,图片瀑布流网站模板题目要求 1.封装类 ?php
class DBDA
{public $fuwuqilocalhost; //服务器地址public $yonghumingroot;//用户名public $mima;//密码 public $dbconnect;//连接对象//操作数据库的方法//$sql代表需要执行的SQL语句//$type代表SQL语…题目要求 1.封装类 ?php
class DBDA
{public $fuwuqilocalhost; //服务器地址public $yonghumingroot;//用户名public $mima;//密码 public $dbconnect;//连接对象//操作数据库的方法//$sql代表需要执行的SQL语句//$type代表SQL语句的类型1代表查询2代表增删改//$shujukuming代表数据库的名称//如果是查询返回二维数组//如果是增删改返回true或falsefunction Query($sql,$type1,$shujukuminghouse){//造连接对象$this-dbconnect new MySQLi($this-fuwuqi,$this-yonghuming,$this-mima,$shujukuming);//判断是否出错if(!mysqli_connect_error()){//如果连接成功,执行SQL语句$result $this-dbconnect-query($sql);//根据语句类型判断if($type1){//如果是查询语句,返回二维数组return $result-fetch_all(); }else{//如果是其他语句返回true或falsereturn $result; }}else{return连接失败; } }
}
? 2.租房子页面 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlnshttp://www.w3.org/1999/xhtml
head
meta http-equivContent-Type contenttext/html; charsetutf-8 /
title租房子---首页/title
/head
bodytable width1000px cellpadding1 border1 ellspacing1
trtd关键字/td
td区域/td
td使用面积/td
td租金/td
td租贷类型/td
td房屋类型/td
td/td
td/td
/tr?phpinclude(DBDA.class.php);$dxnew DBDA();$sqlselect * from house;
$r $dx-Query($sql,1);
//$attr$result-fetch_all();foreach($r as $v)
{
echo
trtd{$v[1]}/td
td{$v[2]}/td
td{$v[3]}/td
td{$v[4]}/td
td{$v[5]}/td
td{$v[6]}/td
tda hrefbianji.php?id{$v[0]}编辑/a/td
tda hrefshanchuchuli.php?id{$v[0]} οnclick\return confirm(确定删除吗)\删除/a/td
/tr;
}?/table
br /
br /
a hreftianjiashuju.phpinput typebutton value添加数据//a
a hrefduotiaojianchaxun.phpinput typebutton value搜索查询 //a
/title
/body
/html 3.删除数据处理界面 ?php
$id $_GET[id];
var_dump($newsid);include(DBDA.class.php);$dxnew DBDA();$sql delete from House where id{$id};
$r $dx-Query($sql,2);
if($r)
{header(location:liebiaoyemian.php);
}
else
{echo 删除失败;
} 4.编辑页面 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlnshttp://www.w3.org/1999/xhtml
head
meta http-equivContent-Type contenttext/html; charsetutf-8 /
title修改房屋数据/title
/head
body
!--newsid--center
h1修改房屋数据/h1?php$id $_GET[id];include(DBDA.class.php);$dxnew DBDA();//echo id;
//var_dump($id);$sqlselect * from house where id{$id};
$r$dx-Query($sql);?form actionbianjichuli.php methodpost
input typehidden nameid value?php echo $r[0][0];?/!--id传过的ID--
div关键字:input typetext nameKeyWord value?php echo $r[0][1];?//div
div区域input typetext nameArea value?php echo $r[0][2];?//div
div使用面积:input typetext nameSquareMeter value?php echo $r[0][3];?//div
div租金:input typetext nameRent value?php echo $r[0][4];?//div
div租贷类型:input typetext nameRentType value?php echo $r[0][5];?//div
div房屋类型:input typetext nameHouseType value?php echo $r[0][6];?//div
divinput typesubmit value更新//div
/form
!--a hrefchakan.phpinput typebutton value查看/a--
/center
/body
/html 5.编辑处理 假面 ?php//使用加载类include(DBDA.class.php);$db new DBDA();$id$_POST[id];//传ID$KeyWord $_POST[KeyWord];$Area $_POST[Area];$SquareMeter $_POST[SquareMeter];$Rent $_POST[Rent];$RentType $_POST[RentType];$HouseType $_POST[HouseType];
$sqlupdate house set KeyWord{$KeyWord},Area{$Area},SquareMeter{$SquareMeter},Rent{$Rent},RentType{$RentType},HouseType{$HouseType} where id{$id};// where id{$id}//echo $sql;$attr $db-Query($sql,2);//var_dump($attr);if($attr){header(location:liebiaoyemian.php); }else{echo 修改失败; } 6.数据添加 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlnshttp://www.w3.org/1999/xhtml
head
meta http-equivContent-Type contenttext/html; charsetutf-8 /
title添加页面/title/head
style.kong{margin:10px 0px 10px 0px;vertical-align: }
/style
body
form actiontianjiachili.php methodposth3添加房屋信息页面/h3 div classkong关键字input typetext nameKeyWord//divdiv classkong区域input typetext nameArea//divdiv classkong使用面积input typetext nameSquareMeter//divdiv classkong租金input typetext nameRent/divdiv classkong租赁类型input typetext nameRentType//divdiv classkong房屋类型input typetext nameHouseType//div
divinput typesubmit value确定/!--插入信息--a hrefliebiaoyemian.phpinput typebutton value返回主页 //a
/div
/form /body
/html 7.数据添加的处理界面 ?php
//$id $_POST[id];
$KeyWord $_POST[KeyWord];
$Area $_POST[Area];
$SquareMeter $_POST[SquareMeter];
$Rent $_POST[Rent];
$RentType $_POST[RentType];
$HouseType $_POST[HouseType];//造连接对象
include(DBDA.class.php);
$dbnew DBDA();//写sql语句
$sqlinsert into house values(,{$KeyWord},{$Area},{$SquareMeter},{$Rent},{$RentType},{$HouseType});
//执行语句
$r$db-Query($sql,2);//($sql,2) 2代表增删改 错在了2上if($r)
{header(location:liebiaoyemian.php);
}
else{echo 执行失败;
}? 8.搜索界面 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlnshttp://www.w3.org/1999/xhtml
head
meta http-equivContent-Type contenttext/html; charsetutf-8 /
title租房子----多条件查询/title
/headbodybody
form actionduotiaojianchaxun.php methodpost
div区域input typecheckbox οnclickCheckAll(this,qy) /全选/div
div?php
include(DBDA.class.php);
$db new DBDA();$sqlqy select distinct Area from house;
$attrqy $db-Query($sqlqy);
//var_dump($attrqy);foreach($attrqy as $v)
{echo input classqy typecheckbox value{$v[0]} nameqy[]/{$v[0]} ;
}
?/divbr /div租赁类型input typecheckbox οnclickCheckAll(this,zl) /全选/div
div?php$sqlzl select distinct RentType from House;
$attrzl $db-Query($sqlzl);foreach($attrzl as $v)
{echo input classzl typecheckbox value{$v[0]} namezl[]/{$v[0]} ;
}
?/divbr /div房屋类型input typecheckbox οnclickCheckAll(this,fw) /全选/div
div?php$sqlfw select distinct HouseType from House;
$attrfw $db-Query($sqlfw);
//var_dump($attrqy);foreach($attrfw as $v)
{echo input classfw typecheckbox value{$v[0]} namefw[]/{$v[0]} ;
}
?/divbr /div关键字input typetext namekeyword idkey /
/form
br /
input typesubmit value搜索 /br /
br /
br /table cellpadding1 cellspacing1 border1 width100%trtd关键字/tdtd区域/tdtd面积/tdtd租金/tdtd租赁类型/tdtd房屋类型/td/tr?php$tj ;
$tj1 11;
$tj2 11;
$tj3 11;
$tj4 11;if(!empty($_POST[qy]))
{$attr $_POST[qy];$str implode(,,$attr);$tj1 Area in ({$str});
}if(!empty($_POST[zl]))
{$attr $_POST[zl];$str implode(,,$attr);$tj2 RentType in ({$str});
}if(!empty($_POST[fw]))
{$attr $_POST[fw];$str implode(,,$attr);$tj3 HouseType in ({$str});
}if(!empty($_POST[keyword]))
{$attr $_POST[keyword];$tj3 keyword like %{$attr}%;
}$tj Where {$tj1} and {$tj2} and {$tj3} and {$tj4};//Where 前加空格$sql select * from House.$tj;
$attrall $db-Query($sql);
//var_dump($attrall);foreach($attrall as $v)
{echo trtd{$v[1]}/tdtd{$v[2]}/tdtd{$v[3]}/tdtd{$v[4]}/tdtd{$v[5]}/tdtd{$v[6]}/td/tr;
}?/table
/body
script typetext/javascript
function CheckAll(a,b)//this表示该
{var qx a.checked;var ck document.getElementsByClassName(b);for(var i 0;ick.length;i){ck[i].checked qx;}
}/script/html
/body
/html 转载于:https://www.cnblogs.com/chenshanhe/p/6861171.html