<?php
// Category Section 1: ម៉ូដសំលៀកបំពាក់ (Clothes & Products)
?>
<div id="bar_title_khmer" style="position: relative; background: url(images/line.png) no-repeat bottom left; font-family: 'Khmer OS Muol Light', 'Koulen', 'Khmer OS', 'Kh Bokor', 'Kh Metal Chrieng', sans-serif; font-size: 20px; color: #f808ea; width: 930px; height: auto; min-height: 40px; line-height: 1.5; margin-top: 10px; margin-bottom: 5px;">
	ម៉ូដសំលៀកបំពាក់
</div>
<div class="clear" style="height: 0px;"></div>
<?php
$sql_c1 = mysql_query("SELECT * FROM tbl_clothes ORDER BY id DESC LIMIT 0,4");
if ($sql_c1 && mysql_num_rows($sql_c1) > 0) {
	while ($row = mysql_fetch_array($sql_c1)) {
		$code_title = !empty($row['code_id']) ? "កូដ: " . $row['code_id'] : "ម៉ូដសំលៀកបំពាក់";
		if (!empty($row['price']) && $row['price'] > 0) {
			$code_title .= " - $" . number_format($row['price'], 2);
		}
		$c_img = !empty($row['image']) && file_exists("images/clothes/" . $row['image']) ? "images/clothes/" . $row['image'] : "images/photo/p1.jpg";
?>
	<a href="?p=clothes&c_id=<?php echo $row['cid']; ?>#txt" title="<?php echo htmlspecialchars($code_title); ?>" style="text-decoration: none;">
		<div id="box_photo">
			<div id="bg_photo">
				<div id="photo_img" style="background: url('<?php echo $c_img; ?>') no-repeat center center; background-size: cover;"></div>
			</div>
			<div class="clear" style="height: 5px;"></div>
			<?php echo htmlspecialchars($code_title); ?>
		</div>
	</a>
<?php 
	}
} 
?>
<div class="clear" style="height: 15px;"></div>

<!-- Category Section 2: ម៉ូដសំលៀកបំពាក់អាពាហ៍ពិពាហ៍ (Wedding Dresses / Suits) -->
<div id="bar_title_khmer" style="position: relative; background: url(images/line.png) no-repeat bottom left; font-family: 'Koulen', 'Khmer OS Muol', 'Khmer OS', 'Kh Bokor', 'Kh Metal Chrieng', sans-serif; font-size: 20px; color: #f808ea; width: 930px; height: auto; min-height: 40px; line-height: 1.5; margin-top: 10px; margin-bottom: 5px;">
	ម៉ូដសំលៀកបំពាក់អាពាហ៍ពិពាហ៍
</div>
<div class="clear" style="height: 0px;"></div>
<?php
$sql_c2 = mysql_query("SELECT * FROM tbl_clothes ORDER BY id ASC LIMIT 4,4");
if ($sql_c2 && mysql_num_rows($sql_c2) > 0) {
	while ($row = mysql_fetch_array($sql_c2)) {
		$code_title = !empty($row['code_id']) ? "កូដ: " . $row['code_id'] : "សំលៀកបំពាក់អាពាហ៍ពិពាហ៍";
		if (!empty($row['price']) && $row['price'] > 0) {
			$code_title .= " - $" . number_format($row['price'], 2);
		}
		$c_img = !empty($row['image']) && file_exists("images/clothes/" . $row['image']) ? "images/clothes/" . $row['image'] : "images/photo/p2.jpg";
?>
	<a href="?p=clothes&c_id=<?php echo $row['cid']; ?>#txt" title="<?php echo htmlspecialchars($code_title); ?>" style="text-decoration: none;">
		<div id="box_photo">
			<div id="bg_photo">
				<div id="photo_img" style="background: url('<?php echo $c_img; ?>') no-repeat center center; background-size: cover;"></div>
			</div>
			<div class="clear" style="height: 5px;"></div>
			<?php echo htmlspecialchars($code_title); ?>
		</div>
	</a>
<?php 
	}
} 
?>
<div class="clear" style="height: 15px;"></div>

<!-- Category Section 3: ម៉ូដសំអាងការ (Wedding Make-up & Beauty) -->
<div id="bar_title_khmer" style="position: relative; background: url(images/line.png) no-repeat bottom left; font-family: 'Koulen', 'Khmer OS Muol', 'Khmer OS', 'Kh Bokor', 'Kh Metal Chrieng', sans-serif; font-size: 20px; color: #f808ea; width: 930px; height: auto; min-height: 40px; line-height: 1.5; margin-top: 10px; margin-bottom: 5px;">
	ម៉ូដសំអាងការ
</div>
<div class="clear" style="height: 0px;"></div>
<?php
$sql_c3 = mysql_query("SELECT * FROM tbl_beauty ORDER BY id DESC LIMIT 0,4");
if ($sql_c3 && mysql_num_rows($sql_c3) > 0) {
	while ($row = mysql_fetch_array($sql_c3)) {
		$str = $row['title'];
		$sp1 = (mb_strlen($str, 'UTF-8') > 40) ? mb_substr($str, 0, 40, 'UTF-8') . '...' : $str;
		$b_img = !empty($row['image']) && file_exists("images/beauty/" . $row['image']) ? "images/beauty/" . $row['image'] : "images/photo/p3.jpg";
?>
	<a href="?p=beauty&b_id=<?php echo $row['id']; ?>#txt" title="<?php echo htmlspecialchars($row['title']); ?>" style="text-decoration: none;">
		<div id="box_photo">
			<div id="bg_photo">
				<div id="photo_img" style="background: url('<?php echo $b_img; ?>') no-repeat center center; background-size: cover;"></div>
			</div>
			<div class="clear" style="height: 5px;"></div>
			<?php echo htmlspecialchars($sp1); ?>
		</div>
	</a>
<?php 
	}
} 
?>
<div class="clear" style="height: 15px;"></div>

<!-- Category Section 4: ព័ត៌មាន (News & Knowledge) -->
<div id="bar_title_khmer" style="position: relative; background: url(images/line.png) no-repeat bottom left; font-family: 'Koulen', 'Khmer OS Muol', 'Khmer OS', 'Kh Bokor', 'Kh Metal Chrieng', sans-serif; font-size: 20px; color: #f808ea; width: 930px; height: auto; min-height: 40px; line-height: 1.5; margin-top: 10px; margin-bottom: 5px;">
	ព័ត៌មាន
</div>
<div class="clear" style="height: 0px;"></div>
<?php
$sql_c4 = mysql_query("SELECT * FROM tbl_all ORDER BY id DESC LIMIT 0,8");
if ($sql_c4 && mysql_num_rows($sql_c4) > 0) {
	while ($row = mysql_fetch_array($sql_c4)) {
		$str = $row['title'];
		$sp1 = (mb_strlen($str, 'UTF-8') > 45) ? mb_substr($str, 0, 45, 'UTF-8') . '...' : $str;
		$a_img = !empty($row['image']) && file_exists("images/all/" . $row['image']) ? "images/all/" . $row['image'] : "images/photo/p4.jpg";
?>
	<a href="?p=all&a_id=<?php echo $row['id']; ?>&act=show#txt" title="<?php echo htmlspecialchars($row['title']); ?>" style="text-decoration: none;">
		<div id="box_photo">
			<div id="bg_photo">
				<div id="photo_img" style="background: url('<?php echo $a_img; ?>') no-repeat center center; background-size: cover;"></div>
			</div>
			<div class="clear" style="height: 5px;"></div>
			<?php echo htmlspecialchars($sp1); ?>
		</div>
	</a>
<?php 
	}
} 
?>
<div class="clear" style="height: 15px;"></div>
