<?php
include("session.php");
include("connect.php");
$id3=$_GET['id'];
?>
<style type="text/css">
address.review{
	font-size:10px;
}
tr.plus{
	background-color:#E8E8E8;
	width:400;
	font-family: "Lucida Grande",Tahoma,Verdana,Lucida,Arial,sans-serif;
}
tr.minus{
	background-color:#FFFFFF;
	width:400;
	font-family: "Lucida Grande",Tahoma,Verdana,Lucida,Arial,sans-serif;
}
tr.page{
	color:blue;
	font-size: 11pt;
}
tr.page a{
	color:blue;
	font-size: 11pt;
}
tr.page a:hover{
	color:pink;
	font-size: 11pt;
}
td.comment{
	font-family: Helvetica, Arial, sans-serif;
	color: black;
	font-size: 10pt;
}
</style>
<?php
$per_page = 10;
$kao=mysql_query("select * from userreview where productID='$id3' ORDER BY reviewID DESC");
$total=ceil(mysql_num_rows($kao)/$per_page);
$page =(isset($_GET['page'])) ? (int) $_GET['page'] :1;
$start=($page-1)*$per_page;
echo "<table align=left width='80%'>";
echo "<tr class=page><td width='10%'>Pages >></td><td>";
	while($i<=$total){
		echo "<a href='ratecomment.php?id=$id3&page=$i' align=center>$i</a>&nbsp ";
		$i++;
	}
echo "</td></tr>";
echo "</table>";
echo "<br/>";
echo "<br/>";	
$a=0;
echo "<table width='100%' border=0 cellpadding=8 cellspacing=8>";
$aaa=mysql_query("select * from userreview where productID='$id3' ORDER BY reviewID DESC limit $start,$per_page");
if(mysql_num_rows($aaa)==0){
	echo "<tr><td align=center>No Review</td></tr>";
}
else{	
	while($display=mysql_fetch_array($aaa)){
		$userID=$display['userID2'];
		if($userID == ""){
			$userID=$display['userID'];
			$bbb=mysql_query("select * from phone_user where userID='$userID'");
			$display2 = mysql_fetch_array($bbb);
			if ($display2['nickName'] == ""){
				$nickName= "UNKNOW USER";
			}else{
				$nickName= $display2['nickName'];
			}
		}else{
			$userID=$display['userID2'];			
			$bbb=mysql_query("select * from customer where no='$userID'");
			$display2 = mysql_fetch_array($bbb);
			if (($display2['fName'] == "")&&($display2['lname'] == "")){
				$nickName= "UNKNOW USER";
			}else{
				$fName= $display2['fname'];
				$lName= $display2['lname'];
				$nickName= $fName." ".$lName;
			}	
		}
		
		$rating=$display['rating'];
		$comment=$display['comment'];
		$date=$display['dateSubmit'];
		$time=$display['timeSubmit'];
		
		
		if($a%2==0){
			echo "<tr class='plus'><td>";
			echo "<table style='width:100%' border=0>";
			echo "<tr>";
			echo "<td style='width:300'><b>$nickName</b></td>";
			echo "<td align=right style='width:120'><address class=review>$date&nbsp;&nbsp;&nbsp;$time</address></td></tr>";
			echo "<tr>";
			echo "<td style='width:300' class='comment'>$comment</td>";
			echo "<td align=right style='width:120' valign='bottom'><b>Rate : </b>$rating</td></tr>
					</table></td></tr>";
		}else if($a%2==1){
			echo "<tr class='minus'><td>";
			echo "<table style='width:100%' border=0>";
			echo "<tr>";
			echo "<td style='width:300'><b>$nickName</b></td>";
			echo "<td align=right style='width:120'><address class=review>$date&nbsp;&nbsp;&nbsp;$time</address></td></tr>";
			echo "<tr>";
			echo "<td style='width:300' class='comment'>$comment</td>";
			echo "<td align=right style='width:120' valign='bottom'><b>Rate : </b>$rating</td></tr>
					</table></td></tr>";
		
		}
		$a++;
	}
	echo "</table>";
}
?>
<?php
include("../closeconnection.php");
?>