很多站长朋友们都不太清楚列表项php代码,今天小编就来给大家整理列表项php代码,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 Php连接数据库获取新闻列表的代码 2、 php代码中列表怎么实现横向排列! 3、 PHP的查询代码 Php连接数据库获取新闻列表的代码<?php
$conn = mysql_connect ( "localhost", "root", "" );
mysql_select_db ( "bookdb" );
mysql_query ( "set names gbk" );
$sql = "select * from book;";
$rs = mysql_query ( $sql );
?>
<html>
<style type="text/css">
* {
font-family: "宋体";
fony-size: 12px
}
;
.tbhead {
background-color: #698CC3;
border: 1px solid #FFFFFF;
color: #FFFFFF;
font-weight: 800;
}
;
.tbleft {
border: 1px dashed #698CC3;
background-color: #EFEFEF;
}
;
.tbright {
background-color: #FFFFFF;
border: 1px dashed #698CC3;
}
;
</style>
<body bgcolor="#9ac5b5">
<h1 align="center">所有书籍信息</h1>
<table style="border: 1px dashed #698CC3; width: 100%; line-height: 200%;"
cellpadding="0px" cellspacing="0px">
<tr>
<td align="right" colspan="7" class="tbhead"><a href="add.php">添加书籍</a></td>
</tr>
<tr>
<th class="tbleft">编号</th>
<th class="tbleft">书名</th>
<th class="tbleft">出版社</th>
<th class="tbleft">出版时间</th>
<th class="tbleft">操作</th>
</tr>
<?php
while ( $arr = mysql_fetch_array ( $rs ) ) {
echo "<tr align='center'>";
echo "<td class='tbright'>" . $arr ["bid"] . "</td>";
echo "<td class='tbright'>" . $arr ["bname"] . "</td>";
echo "<td class='tbright'>" . $arr ["bcbs"] . "</td>";
echo "<td class='tbright'>" . $arr ["btime"] . "</td>";
echo "<td class='tbright'><a href='del.php?bid=" . $arr ["bid"] . "'>删除</a> <a href='update.php?bid=" . $arr ["bid"] . "'>修改</a></td>";
echo "</tr>";
}
mysql_free_result ( $rs );
mysql_close ( $conn );
?>
</table>
</body>
</html>
php代码中列表怎么实现横向排列!使用css来实现
css
ul{list-style: none;}
li{
width: 60px;
float: left;
margin: 0 10px 0 0;
padding: 5px;
}
a{
display: block;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
html
<strong>友情链接:</strong>
<ul>
<li><a href="#">子标题1</a></li>
<li><a href="#">子标题2</a></li>
<li><a href="#">子标题3</a></li>
<li><a href="#">子标题4</a></li>
<li><a href="#">子标题5</a></li>
<li><a href="#">子标题6</a></li>
</ul>
实际使用时,使用php循环来生成li标签即可
PHP的查询代码1.php代码 a.php?t=1
//a.php t是列表type
$type =$_GET['t'];
if($type==='1')
{
$where_sql = "where lxtc like '乐享%'";
}else if($type==='2')
{
$where_sql = "where lxtc like '新融合%'";
}elseif($type==='3'){
$where_sql = "where lxtc like '新融合%' OR lxtc like '乐享%'";
}else{
$where_sql =' where 1';//所有的
}
$sql = "select * from `table` ".$where_sql;
$num_sql = "select count(*)as num from `table`".$where_sql;
//获取统计总数
//$db是mysql对象 其实就是查询两条sql语句的对象 简写如下
$db->query($num_sql);
//列表
$row= $db->query($sql);
//循环$row就是结果
单单数据逻辑不麻烦,难点应该是sql语句的书写。用到like % 第二用到OR连接,
关于列表项php代码的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于列表项php代码 php list函数的详细内容...