<?php
include("../session.php");
include("../connect.php");

$id=$_GET['id'];
$user=$_GET['user'];
$a=0;
echo "<table width=410 border=0 cellpadding=8 cellspacing=8>";
$aaa=mysql_query("select * from userreview where productID='$id' ORDER BY reviewID DESC");
	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:400' border=0>";
		echo "<tr>";
		echo "<td style='width:280'><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:280'>$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:400' border=0>";
		echo "<tr>";
		echo "<td style='width:280'><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:280'>$comment</td>";
		echo "<td align=right style='width:120' valign='bottom'><b>Rate : </b>$rating</td></tr>
				</table></td></tr>";
	
	}
	$a++;
}
echo "</table>";
}
?>
<link href="header.css" rel="stylesheet" type="text/css"/>