require_once("initpage.php");
//require_once('Connections/RoomDB.php');
if(isset($_SESSION['UserId'])){
include_once('logout.php') ;
}
if(isset($_REQUEST['start'])) {
$start = $_REQUEST['start'];
} else {
$start = 0;
}
if(isset($_REQUEST['page'])){
$page = $_REQUEST['page'];
} else {
$page = 0;
}
$limit = 3;
$template=new Template("./templates");
$template->set_file(array("MainPage" => "review.html" , "RequestForm" => "tableReview.html" ));
/*
,"viewitemAddButtonForm" => "viewitemAddButton.html","viewitemTableForm" => "viewitemTable.html","viewitemEditDeleteButtonForm" => "viewitemEditDeleteButton.html"));
*/
mysql_select_db($database_RoomDB, $RoomDB);
$query_total = "SELECT count(*) num FROM `review` where ReviewShow = 'Y' and (ReviewMarkDelete IS NULL or ReviewMarkDelete = '0000-00-00' )";
$result_total = mysql_query($query_total, $RoomDB) or die(mysql_error());
$total_item = mysql_fetch_assoc($result_total);
$total = $total_item['num'];
mysql_free_result($result_total);
$query_item = "SELECT `ReviewDetail` , `ReviewName` , date( `ReviewDate` ) ReviewDate , `ReviewPhoto` FROM `review` where ReviewShow = 'Y' and (ReviewMarkDelete IS NULL or ReviewMarkDelete = '0000-00-00' ) order by ReviewDate desc limit $start,$limit";
$item = mysql_query($query_item, $RoomDB) or die(mysql_error());
$row_item = mysql_fetch_assoc($item);
$totalRows_item = mysql_num_rows($item);
/* if (isset($_SESSION['UserId'])){
$template->do_parse ( "viewitemAddButton" , "viewitemAddButtonForm" );
} */
$i=0;
do {
if (fmod($i,2) > 0) {
$template->set_var ( "TRColor" , "bgcolor='#e0e0e0'" );
}else{
$template->set_var ( "TRColor" , "" );
}
$srcImg = "photo_review/".$row_item['ReviewPhoto'];
if ( $row_item['ReviewPhoto'] == Null ) {
$srcImg = "images/noimage.jpg";
}
$template->set_var ( "reviewphoto" , $srcImg);
$template->set_var ( "reviewname" , $row_item['ReviewName']);
$template->set_var ( "reviewdetail" , preg_replace("/\n/i","
",$row_item["ReviewDetail"]) ); // $row_item['ReviewDetail']);
$template->set_var ( "reviewdate" , ConvertDateSQL2Date($row_item['ReviewDate']) );
/*
if(isset($_SESSION['ReviewId'])) {
$template->set_var ( "ReviewId" , $row_item['ReviewId']);
//$template->do_parse ( "viewitemEditDeleteButton" , "viewitemEditDeleteButtonForm" );
}else{
//$template->set_var ( "viewitemEditDeleteButton" , "");
}
*/
// $template->do_parse ( "viewitemTable" , "viewitemTableForm" ,true);
$template->do_parse ( "interface" , "RequestForm" , true);
$i++;
} while ($row_item = mysql_fetch_assoc($item));
$page = ceil($total/$limit);
if ($page > 1) {
for($i=1;$i<=$page;$i++){
if($_GET['page']==$i){
$table_desc .= "[$i]";
}
else{
$table_desc .= "[$i]";
}
}
}
$table_desc;
$template->set_var ( "paginate" , $table_desc );
mysql_free_result($item);
// $template->do_parse ( "interface" , "RequestForm" );
$template->do_parse("output","MainPage");
$template->do_out("output");
?>