本例程序使用的是access数据库为"图书基本情况的数据库"请读者自己配置的odbc数据源
源码:
<html>
<head>
<title>欢迎来网上图书馆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" background="image/ACSNDSTN.GIF">
<div align="center"><font face="Courier New, Courier, mono"><font size="+2"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#AF80FF">欢迎来网上借书室</font>
</b></font></font> <font size="+2"><?php
$connid1=@odbc_connect("library","admin",""); //library为odbc数据源名称//
$result1=@odbc_exec($connid1,"select count(*) FROM bookstable ");
if (odbc_fetch_into($result1,0,&$rarra))
$total=$rarra[0]; //计算出总数//
if ($total% 10==0)
$price=(int)($total/10); //10个为一页//
else
$price=(int)($total/10)+1;
odbc_close($connid1);
?>
<?php
if ($sg>$price) { $sg=$price; }
if ($sg<1) { $sg=1; }
?> </font> </div>
<table border="0" width="192" cellspacing="0" cellpadding="0" align="right" height="20">
<tr>
<td>
<div align="right"><font color="#0165A0" size="2">图书馆共藏</font><font color="#0165A0"><?php echo $total;?><font size="2">本书</font>,<font size="2">第</font><?php echo $sg."/".$price;?><font size="2">页</font></font></div>
</td>
</tr>
</table>
<p> </p>
<table border="1" width="757" cellspacing="1" cellpadding="1" align="center" bordercolor="#FFFFFF" height="56" >
<tr>
<td width="52" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">图书总编</font></div>
</td>
<td width="165" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">图书名称</font></div>
</td>
<td width="45" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">作者</font></div>
</td>
<td width="153" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">出版社</font></div>
</td>
<td width="35" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">单价</font></div>
</td>
<td width="114" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">书号</font></div>
</td>
<td width="54" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">计价单位</font></div>
</td>
<td width="30" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2">数量</font></div>
</td>
<td width="46" bgcolor="#99CCFF" height="3">
<div><font color="#6600CC" size="2"></font></div>
</td>
</tr>
<?php
$i1=0;
$couu=$sg*10-9;
$connid=@odbc_connect("library","admin","");
$result=@odbc_exec($connid,"select * FROM bookstable");
while(@odbc_fetch_into($result,$couu,&$rarr)){
?> <?php
if ($couu%2==0){
?>
<form method="POST" name="gwc" action=<?php if ($sl>0) { echo "gwc.php?&userid="; echo $rarr[0]; } else echo "$PHP_SELF" ?>>
<tr>
<td width="52" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[0]);?></font></td>
<td width="165" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[1]);?></font>
</td>
<td width="45" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[2]);?></font></td>
<td width="153" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[3]);?></font>
</td>
<td width="35" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[4]);?></font></td>
<td width="114" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[5]);?></font>
</td>
<td width="35" bgcolor="#FFFFF0" height="2"><font color="#6600FF" size="2">本</font></td>
<td width="35" bgcolor="#FFFFF0" height="2"><input type="text" name="sl" size="2"></td>
<td width="35" bgcolor="#FFFFF0" height="2"><input type="submit" name="b1" size="3" value="选定" ></td> </tr>
</form>
<?php
}
else
{
?>
<form method="POST" name="gwc" action=<?php if ($sl>0) { echo "gwc.php?&userid="; echo $rarr[0]; } else echo "$PHP_SELF" ?>>
<tr>
<td width="52" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[0]);?></font></td>
<td width="165" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[1]);?></font>
</td>
<td width="45" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[2]);?></font></td>
<td width="153" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[3]);?></font>
</td>
<td width="35" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[4]);?></font></td>
<td width="114" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="2"><? echo trim($rarr[5]);?></font>
</td>
<td width="35" bgcolor="#F2F2F2" height="2"><font color="#6600FF" size="3">本</font></td>
<td width="35" bgcolor="#F2F2F2" height="2"><input type="text" name="sl" size="2"></td>
<td width="35" bgcolor="#F2F2F2" height="2"><input type="submit" name="b1" size="3" value="选定" ></td>
</tr>
</form>
<?php
}
?>
<?php
$couu++;
if ($couu>=$sg*10+1) break;
}
?>
</table>
<?php
echo "<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n";
?> <?php
if ($total>1){
?>
<table border="0" width="27%" cellspacing="0" cellpadding="0" align="center" height="20">
<tr>
<?php
if ($sg>1){
?>
<td width="33%" height="36">
<input type="button" value="第一页" name="first" onClick="top.document.location='split.php?&sg=1';">
</td>
<td width="33%" height="36">
<input type="button" value="上一页" name="previou" onClick="top.document.location='split.php?&sg=<?php if ($sg>1) { echo ($sg-1); } else { echo "1"; } ?>';">
</td>
<?php
}
if ($sg<$price){
?>
<td width="33%" height="36"><input type="button" value="下一页" name="next" onClick="top.document.location='split.php?&sg=<?php if ($sg<$price) { echo ($sg+1); } else { echo $price; } ?>';"></td>
<td width="33%" height="36"><input type="button" value="最后页" name="last" onClick="top.document.location='split.php?&sg=<?php echo $price; ?>';"></td>
<?php
}
?>
</tr>
</table>
<?php
}
odbc_close($connid);
?>
</body>
</html>
|