您的位置:首页 > 数据库

利用数据库管理网页模块

2011-09-26 20:46 176 查看
不知道题目是不是起的合适呢,不过这是我的理解啦,对网页进行动态管理,会使我们的代码数量减少很多,不用复制粘贴很多遍了。



如上图,网页管理左侧的是left.php。个人资料 商品管理...是一个一个的模块,用如下代码使其完成循环

<?php

$qq=mysql_num_rows($rs);//遍历每一条数据库记录,$rs是表中存放type属性的字段

for($i=1;$i<=$qq;$i++){

$rq="select * from type where type='".$i."'";

$s=mysql_query($rq);

$ary=mysql_fetch_array($s);//我标红的部分是for的循环体,type字段中有几种类型,for就循环几次,客户就能看到几个模块。

?>

<TABLE cellSpacing=0 cellPadding=0 width=158 align=center>

<TBODY>

<TR>

<TD class=menu_title id=menuTitle1

onmouseover="this.className='menu_title2';" onclick=showsubmenu(0)

onmouseout="this.className='menu_title';"

background=left.files/admin_left_1.gif

height=25><span><B><%=trim(rs("userName"))%><?php echo $ary['name'];?></B></span></TD>

</TR>

<TR>

<TD id=submenu0>

<DIV class=sec_menu style="WIDTH: 158px ">

<TABLE cellSpacing=0 cellPadding=0 width=135 align=center>

<TBODY>

<?php //从list表中获取$i的值($i是type表中的类型的数量)从而能使模块中的各个栏目显示出来

$w="select * from list where type='".$i."'";

$aaa=mysql_query($w);

while($rowss=mysql_fetch_assoc($aaa)){

?>

<TR>

<TD height=20><A

href="<?php echo $rowss['adress'];?>"target=mainFrame><?php echo $rowss['title'];?></A></TD>//它能使type中的title循环显示

</TR>

<?php

}

?>

</TBODY></TABLE>

</DIV>

<DIV style="WIDTH: 158px">

<TABLE cellSpacing=0 cellPadding=0 width=135 align=center>

<TBODY>

<TR>

<TD height=20></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE>

<?php

}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: