ทดสอบ PHP

Theeradet
ติดตาม ผู้ติดตาม 
ติดต่อ

<?

session_start();

include("db.php");

include("function_inc.php");

include("config.php");

?>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- InstanceBeginEditable name="doctitle" -->

<title>Book Store</title>

<!-- InstanceEndEditable -->

<!-- InstanceBeginEditable name="head" -->

<script type="text/javascript" src="iepngfix_tilebg.js"></script>

<link rel="stylesheet" type="text/css" href="stylesheet.css" />

<style type="text/css">

.ie6_png {behavior: url("iepngfix.htc") }

.ie6_png img{behavior: url("iepngfix.htc") }

</style>

<!-- InstanceEndEditable -->

</head>

<body>

<!-- header //-->

<!-- start -->

<table cellpadding="0" cellspacing="0" border="0" align="center" class="bg_main">

<tr>

<td class="bg2_main">

<table cellpadding="0" cellspacing="0" border="0" align="center" class="bg3_main">

<tr>

<td class="bg4_main">

<table cellpadding="0" cellspacing="0" border="0">

<tr>

<td>

<table cellpadding="0" cellspacing="0" border="0">

<tr>

<td class="logo">

<a href="index.php">

<img src="images/logo.gif" border="0" alt="" width="156" height="38">

</a>

</td>

<td class="header">

<table border="0" cellspacing="0" cellpadding="0">

<tr>

<td align="center">

<table border="0" cellspacing="0" cellpadding="0" align="center" style="width:120px">

<tr>

<td class="al_left"><strong>User : Guest</strong>

<form name="currencies" action="index.php" method="get"></form>

</td>

</tr>

</table>

</td>

<td style="width:50%;"><img src="images/part.gif" border="0" alt="" width="1" height="58"></td>

<td>

<table border="0" cellspacing="0" cellpadding="0" align="center" style="width:10px">

<tr>

<td class="al_left">&nbsp;</td>

</tr>

</table>

</td>

<td style="width:50%;"><img src="images/part.gif" border="0" alt="" width="1" height="58">

</td>

<td>

<table cellpadding="0" cellspacing="0" border="0" align="center" style="width:130px;">

<tr>

<td class="z1 al_left"><b>Shopping Cart:</b> now in your cart &nbsp;&nbsp;<a href="shopping_cart.php">0 items</a>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td class="row_2"><div>

<table cellpadding="0" cellspacing="0" border="0" class="menu ie6_png">

<tr>

<td style="width:10%;"><img src="images/spacer.gif" border="0" alt="" width="1" height="1">

</td>

<td><a href="index.php"><img src="includes/languages/english/images/buttons/m1.png" border="0" alt="" width="67" height="10"></a>

</td>

<td class="m_sep"><img src="images/m_sep.gif" border="0" alt="" width="1" height="13">

</td>

<td><a href="products_new.php"><img src="includes/languages/english/images/buttons/m2.png" border="0" alt="" width="94" height="10"></a>

</td>

<td class="m_sep"><img src="images/m_sep.gif" border="0" alt="" width="1" height="13">

</td>

<td><a href="specials.php"><img src="includes/languages/english/images/buttons/m3.png" border="0" alt="" width="57" height="10"></a>

</td>

<td class="m_sep"><img src="images/m_sep.gif" border="0" alt="" width="1" height="13">

</td>

<td><a href="login.php"><img src="includes/languages/english/images/buttons/m4.png" border="0" alt="" width="76" height="10"></a>

</td>

<td class="m_sep"><img src="images/m_sep.gif" border="0" alt="" width="1" height="13">

</td>

<td><a href="contact_us.php"><img src="includes/languages/english/images/buttons/m5.png" border="0" alt="" width="73" height="10"></a>

</td>

<td style="width:10%;"><img src="images/spacer.gif" border="0" alt="" width="1" height="1">

</td>

</tr>

</table>

</div>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<div class="s_tl">

<div class="s_tr">

<div class="s_bl">

<div class="s_br">

<div class="width_100">

<!-- end -->

<!-- start -->

<!-- end --><!-- header_eof //-->

<!-- body //-->

<table border="0" class="main_table" cellspacing="0" cellpadding="0">

<tr>

<td class="box_width_td_left">

<table border="0" class="box_width_left" cellspacing="0" cellpadding="0">

<!-- left_navigation //-->

<!-- categories //-->

<tr>

<td>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBoxHeading_table">

<tr>

<td class="infoBoxHeading_td">

<table cellpadding="0" cellspacing="0" border="0" class="table2">

<tr>

<td class="td2">

<table cellpadding="0" cellspacing="0" border="0" class="table3">

<tr>

<td class="td3">

<table cellpadding="0" cellspacing="0" border="0" class="table4">

<tr>

<td class="td4">

<div>Categories</div>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox_table">

<tr>

<td class="infoBox_td">

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBoxContents_table">

<tr>

<td class="boxText">

<table cellpadding="0" cellspacing="0" border="0" class="table2">

<tr>

<td class="td2">

<ul>

<?

try

{

$sql="select c.*, (select count(*) from products where category_id=c.category_id) as total from categories as c";

$stmt=$conn->query($sql);

}

catch(Exception $e)

{

print($e->getMessage());

}

while($row=$stmt->fetch())

{

?>

<li class="bg_list"><a href="index.php?cid=<?=$row[0]?>"><?=$row[1]?>(<?=$row['total']?>)</a>

</li>

<?

}

?>

</ul>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<!-- categories_eof //-->

<!-- specials //-->

<tr>

<td>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBoxHeading_table">

<tr>

<td class="infoBoxHeading_td">

<table cellpadding="0" cellspacing="0" border="0" class="table2">

<tr>

<td class="td2">

<table cellpadding="0" cellspacing="0" border="0" class="table3">

<tr>

<td class="td3">

<table cellpadding="0" cellspacing="0" border="0" class="table4">

<tr>

<td class="td4">

<div>Specials</div>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox_table">

<tr>

<td class="infoBox_td">

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBoxContents_table">

<tr>

<td align="center" class="boxText">

<table cellpadding="0" cellspacing="0" border="0" class="table2">

<tr>

<td class="td2">

<table cellpadding="0" cellspacing="0" border="0">

<tr>

<td class="pic_padd"><a href="product_info.php?products_id=5"><img src="images/005.jpg" border="0" alt="Product #005" title=" Product #005 " width="82" height="126"></a>

</td>

</tr>

<tr>

<td class="name_padd"><span><a href="product_info.php?products_id=5">Product #005</a></span>

</td>

</tr>

<tr><td class="price_padd"><div style="float:left;"><del>$35.99</del></div> <div style="float:right;"><span class="productSpecialPrice">$30.00</span></div></td></tr>

</table>

</td></tr>

</table></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<!-- specials_eof //-->

<!-- best_sellers //-->

<tr>

<td valign="top">

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBoxHeading_table">

<tr>

<td class="infoBoxHeading_td">

<table cellpadding="0" cellspacing="0" border="0" class="table2">

<tr><td class="td2">

<table cellpadding="0" cellspacing="0" border="0" class="table3">

<tr><td class="td3">

<table cellpadding="0" cellspacing="0" border="0" class="table4">

<tr><td class="td4"><div>Bestsellers</div></td></tr>

</table>

</td></tr>

</table>

</td></tr>

</table></td>

</tr>

</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox2_table">

<tr>

<td class="infoBox2_td"><table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBoxContents2_table">

<tr>

<td class="boxText"><table cellpadding="0" cellspacing="0" border="0" class="table2">

<tr><td class="td2"><ul><li class="bg_list2_un">

<a href="product_info.php?products_id=1"><strong>01</strong>.&nbsp;Product #001</a></li><li class="bg_list2">

<a href="product_info.php?products_id=2"><strong>02</strong>.&nbsp;Product #002</a></li><li class="bg_list2">

<a href="product_info.php?products_id=3"><strong>03</strong>.&nbsp;Product #003</a></li><li class="bg_list2">

<a href="product_info.php?products_id=4"><strong>04</strong>.&nbsp;Product #004</a></li><li class="bg_list2">

<a href="product_info.php?products_id=5"><strong>05</strong>.&nbsp;Product #005</a></li><li class="bg_list2">

<a href="product_info.php?products_id=6"><strong>06</strong>.&nbsp;Product #006</a></li><li class="bg_list2">

<a href="product_info.php?products_id=7"><strong>07</strong>.&nbsp;Product #007</a></li><li class="bg_list2">

<a href="product_info.php?products_id=8"><strong>08</strong>.&nbsp;Product #008</a></li></ul></td></tr>

</table></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<!-- best_sellers_eof //-->

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td class="content_width_td">

<div class="banner"><a href="index.php?action=banner&amp;goto=2" target="_blank"><img src="images/banner_02.jpg" border="0" alt="Banner2" title=" Banner2 " width="608" height="247"></a></div>

<div class="width_100">

<!-- here -->

<!-- InstanceBeginEditable name="EditRegion" -->

<!-- Welcome_box_start -->

<!-- <table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr><td class="main"></td></tr>

<tr><td></td></tr>

<tr><td class="main"></td></tr>

</table> -->

<!-- Welcome_box_end -->

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="cont_heading_table">

<tr>

<td class="cont_heading_td">What's New Here?</td>

</tr>

</table>

<div style="background:url(images/line_x.gif) 0px 0px repeat-x;padding:0px 0px 1px 0px;"><img src="images/spacer.gif" border="0" alt="" width="1" height="1"></div>

<table cellpadding="0" cellspacing="0" border="0"><tr><td class="padd_3">

<!-- new_products //-->

<table border="0" width="" cellspacing="0" cellpadding="0">

<tr>

<td class="tableBox_output_td main"><table border="0" width="" cellspacing="0" cellpadding="0">

<?

$cid=intval($_GET['cid']);

if(empty($cid))

{

$sql="select count(*) from products";

}

else

{

$sql="select count(*) from products where category_id=$cid";

}

$stmt=$conn->query($sql);

$row=$stmt->fetch();

$totalrecord=$row[0];

if(empty($cid))

{

$sql="select *, date(product_date_added) as product_add from products";

}

else

{

$sql="select *, date(product_date_added) as product_add from products where category_id=?";

}

$pagesize=3;

$totalpage=ceil($totalrecord/$pagesize);

$page=intval($_GET['page']);

if(empty($page))

$page=1;

$start=($page-1)*$pagesize;

$sql.=" limit $start, $pagesize";

//$stmt=$conn->query($sql);

$stmt=$conn->prepare($sql);

$stmt->execute(array($cid));

while($row=$stmt->fetch())

{

?>

<tr>

<td align="left"><table cellpadding="0" cellspacing="0" border="0" class="tep_draw_prod_top_table">

<tr>

<td class="tep_draw_prod_top_td"><div class="pic_padd"><a href="product_info.php?products_id=<?=$row['product_id']?>"><img src="images/<?=$row['product_image']?>" border="0" alt="Divine Justice" title=" Divine Justice " width="90" height="117" /></a></div>

<div>

<div class="name name_padd"><a href="product_info.php?product_id=<?=$row['product_id']?>"><?=$row['product_name']?></a></div>

<div class="ofh">

<div class="price_padd vam">&nbsp;&nbsp;<span class="productSpecialPrice">ราคา <?=number_format($row['product_price'],2)?></div>

<div class="listing data_padd"><em>Date Added: <?=thaidate($row['product_add'])?></em></div>

</div>

<div class="desc desc_padd">รายละเอียด <?=$row['product_desc']?></div>

<div class="button_padd ofh">

<div class="data_padd fl_right"><a href="shopping_cart.php?action=buy_now&product_id=<?=$row['product_id']?>"><img src="includes/languages/english/images/buttons/button_add_to_cart1.gif" border="0" alt="" width="79" height="28" /></a></div>

<div class="data_padd fl_left"><a href="product_info.php?product_id=<?=$row['product_id']?>"><img src="includes/languages/english/images/buttons/button_details.gif" border="0" alt="" width="57" height="28" /></a></div>

</div>

</div></td>

</tr>

</table></td>

</tr>

<tr>

<td class="prod_line_x padd_gg" colspan="1"><img src="images/spacer.gif" border="0" alt="" width="1" height="1" /></td>

</tr>

<tr>

<td align="left"><table cellpadding="0" cellspacing="0" border="0" class="tep_draw_prod_top_table">

<tr>

<td class="tep_draw_prod_top_td">&nbsp;</td>

</tr>

</table></td>

</tr>

<?

}

?>

</table></td>

</tr>

</table>

<div style="background:url(images/line_x.gif) 0px 0px repeat-x;padding:0px 0px 1px 0px;"><img src="images/spacer.gif" border="0" alt="" width="1" height="1"></div>

<table border="0" cellspacing="0" cellpadding="0" class="result result_top_padd">

<tr>

<td><b><?=$totalrecord?></b> products</td>

<td class="result_right">Result Pages:

<?

for($i=1;$i<=$totalpage;$i++)

{

if($i==$page)

print("<b>$i</b> ");

else

print("<a href='index.php?page=$i&cid=$cid' class='pageResults'>$i </a>");

}

?>

</td>

</tr>

</table>

<!-- new_products_eof //-->

</td></tr></table>

<!-- InstanceEndEditable -->

</div>

</td>

<!-- body_text_eof //-->

<td class="box_width_td_right"><table border="0" class="box_width_right" cellspacing="0" cellpadding="0">

<!-- right_navigation //-->

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

<!-- body_eof //-->

<!-- footer //-->

</div>

</div>

</div>

</div>

</div>

</td></tr>

<tr><td>

<table cellpadding="0" cellspacing="0" border="0" align="center" class="footer">

<tr><td><table cellpadding="0" cellspacing="0" border="0" class="footer_td"><tr><td><img src="images/p1.gif" border="0" alt="" width="162" height="26"></td></tr></table></td>

<td class="footer2_td"><span><a href="special.php">Specials</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="advanced_search.php">Advanced Search</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="reviews.php">Reviews</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="create_account.php">Create an Account</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="login.php">Log In</a></span><br>&nbsp;&nbsp;Copyright &copy; <?=date("Y")?> <a href="index.php">Book Store</a> &nbsp;&nbsp; <b><a href="privacy.php">Privacy Notice</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="conditions.php">Conditions of Use</a></b></td>

</tr>

</table>

</td></tr></table>

</td></tr></table>

<!-- footer_eof //-->

</body>

<!-- Mirrored from osc3.template-help.com/osc_22496/index.php by HTTrack Website Copier/3.x [XR&CO'2008], Wed, 06 May 2009 02:55:16 GMT -->

<!-- InstanceEnd --></html>

บันทึกนี้เขียนที่ GotoKnow โดย  ใน สมุดโน้ตคนจำยาก



ความเห็น (0)