<?session_start();?>
<html> <head>
<title>查书</title> <?
$name=chop($name); $author=chop($author); $publish=chop($publish); $conn=mysql_connect("localhost");
$sql=mysql_select_db("e_shop",$conn);
if (empty($author)&&empty($publish)&&empty($name)) {
?>
<td>
<div align="center"><img src="image/searched.gif" width="400" height="75"></div>
</td> <?
exit;
} if($select2=="=")
{
if($r=="and")
{
if ($name!="")
{$a="name='$name'";}
else
{$a="1";}
if ($author!="")
{$b="author='$author'";}
else
{$b="1";}
if($publish!="")
{$c="publish='$publish'";}
else
{$c="1";}
}
elseif($r=="or")
{
if ($name!="")
{$a="name='$name'";}
else
{$a="0";}
if ($author!="")
{$b="author='$author'";}
else
{$b="0";}
if($publish!="")
{$c="publish='$publish'";}
else
{$c="0";}
} echo "<br>";
$result=mysql_db_query("e_shop","select * from book where $a $r $b $r $c",$conn); if(mysql_num_rows($result)==0) { ?> <td>
<div align="center"><img src="image/notsearch.gif" width="400" height="75"></div>
</td> <? exit;}
} if($select2=="like")
{
if($r=="and")
{
if ($name!="")
{$a="name like'%$name%'";}
else
{$a="1";}
if ($author!="")
{$b="author like'%$author%'";}
else
{$b="1";}
if($publish!="")
{$c="publish like '%$publish%'";}
else
{$c="1";}
}
elseif($r=="or")
{
if ($name!="")
{$a="name like '%$name%'";}
else
{$a="0";}
if ($author!="")
{$b="author like '%$author%'";}
else
{$b="0";}
if($publish!="")
{$c="publish like '%$publish%'";}
else
{$c="0";}
} echo "<br>";
$result=mysql_db_query("e_shop","select * from book where $a $r $b $r $c",$conn); if(mysql_num_rows($result)==0) { ?> <td>
<div align="center"><img src="image/notsearch.gif" width="400" height="75"></div>
</td> <? exit;} }
?>
<table align=center border=0 cellpadding=0 cellspacing=0 width=760>
<tbody> <tr>
<td>
<table align=center bgcolor=mediumpurple border=0 cellpadding=0
cellspacing=1 width="96%">
<tbody>
<tr bgcolor=#e8e8e8>
<td height=30 width="10%">选购</td>
<td height=30 width="35%">书名</td>
<td height=30 width="18%">作者</td>
<td height=30 width="18%">出版社</td>
<td height=30 width="14%">出版日期</td>
<td height=30 width="6%">价格</td>
</tr>
<?
$recPerPage=3;
// connect to server
$rowOfRec=mysql_num_rows($result);
if($rowOfRec%$recPerPage==0){
$pages=floor($rowOfRec/$recPerPage);
}
else{
$pages=floor($rowOfRec/$recPerPage)+1;
}
if($page<1||$page>$pages){
$page=1;
}
$init_pos=($page-1)*$recPerPage;
if($page==$pages){
$abc=$rowOfRec-1;
}
else{
$abc=($init_pos+$recPerPage-1);
}
for($pos=$init_pos;$pos<=$abc;$pos++){
mysql_data_seek($result,$pos);
$row=mysql_fetch_object($result);
?>
<tr bgcolor=#ffffff>
<td>
<form action="addToCart1.php?page=<?=$page?>" id=form1 method=post name=form1>
<input name=bookid
type=hidden value=<?=$row->id?>>
<input name=bookname type=hidden
value="<?=$row->name?>">
<input name=publish type=hidden
value=<?=$row->publish?>>
<input name=unitprice type=hidden value=<?=$row->price?>>
<input
class=inputbox maxlength=2 name=num size=2>
<input alt=订购 class=inputbox onClick=addtocart(this.form); type=button value=选定 name="button">
</form>
</td>
<td><a
href="detailOfBook.php?bookid=<?=$row->id?>">
<?=$row->name?>
</a></td>
<td>
<?=$row->author?>
</td>
<td>
<?=$row->publish?>
</td>
<td>
<?$pubDate=$row->puDate;
$year=substr($pubDate,0,4);
$month=substr($pubDate,5,2);
echo $year.".".$month;
//echo $year//.".".$pubDate["mon"]
?>
</td>
<td>
<?=$row->price?>
</td>
</tr>
<?}?>
</tbody>
</table>
<form action="<?echo $PHP_SELF;?>?categoryID=<?=$categoryID?>&select2=<?=$select2?>&r=<?=$r?>&name=<?=$name?>&publish=<?=$publish?>&author=<?=$author?>" id=form2 method=post
name=form2 style="MARGIN: 0px">
<input type=hidden value="yes" name="ok">
一共找到<span class=color1>
<?=$rowOfRec?>
</span>本符合要求的书,
<?if($page>1){
?>
<a href="<?$PHP_SELF?>?<?=SID?>&categoryID=<?=$categoryID?>&page=<?=($page-1)?>&init_pos=<?=($init_pos-$recPerPage)?>&select2=<?=$select2?>&r=<?=$r?>&name=<?=$name?>&publish=<?=$publish?>&author=<?=$author?>">上一页</a>
<?
}
?>
<?if($page<$pages){
?>
<a href="<?$PHP_SELF?>?<?=SID?>&categoryID=<?=$categoryID?>&page=<?=($page+1)?>&init_pos=<?=($init_pos+$recPerPage)?>&select2=<?=$select2?>&r=<?=$r?>&name=<?=$name?>&publish=<?=$publish?>&author=<?=$author?>">下一页</a>
<?
}
?>
请输入页码:
<input class=inputbox maxlength=4 name=page
size=4>
<?=$page?>
/
<?=$pages?>
</form>
</td> </tr>
<tr>
<td>
<form action="addToCart1.php?categoryID=<?=$categoryID?>&<?=SID?>" method=post id=form3 name=form3>
<input name=id type=hidden >
<input name=name type=hidden>
<input name=press type=hidden>
<input name=unitPrice type=hidden>
<input name=quantity type=hidden>
</form>
</td> </tr>
<tr bgcolor=#ffffff>
<td colspan=6 align=center height=30>
<input class='inputbox' type=button value=查看购物车 id=button1
onClick=location.href='view_cart1.php?categoryID=<?=$categoryID?>&<?=SID?>' name="button">
</td>
</tr> </tbody>
</table>
<table width="50%" border="0" cellspacing="0" cellpadding="0" height="58" align="center">
<tr> <td>
<div align="center"><img width="400" height="75" src="image/s.jpg"></div>
</td> </tr>
</table> <p> </p>
</body> </html>
|
|