|
|
|
ช่วยเขียนคำอธิบายโค้ด PHP ให้หน่อยครับ ขอบคุณมากครับ |
|
|
|
|
|
|
|
webbord_view.php
Code (PHP)
<?php
//show post quiz
$quiz_id=intval($_GET['quiz_id']);
$board_quiz=mysql_query("select * from board_quiz where quiz_id=".$quiz_id);
$quiz=mysql_fetch_assoc($board_quiz);
////answer post
if(!empty($_POST['answer'])){
$quiz_id=mysql_real_escape_string($_POST['quiz_id']);
$ans_detail=mysql_real_escape_string($_POST['ans_detail']);
$ans_name=mysql_real_escape_string($_POST['ans_name']);
$cmd="insert into board_ans (quiz_id,ans_detail,ans_name,ans_date) values ('$quiz_id','$ans_detail','$ans_name',now())";
$strQuery=mysql_query($cmd);
if($strQuery){
echo"<script>alert('บันทึกข้อมูลสำเร็จ'); window.location='index.php?page=webboard_view.php&quiz_id=$quiz_id';</script>";
}
}
?>
<div style="padding:5px;"><a href="index.php?page=webboard.php">เว็บบอร์ด</a> > แสดงรายละเอียด</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#2F98BB">
<tr>
<td bgcolor="#2F98BB" style="padding:4px; color:#FFFFFF; font-size:14px; border-radius:5px;"><strong>TOPIC</strong> : <?=$quiz['quiz_topic'];?></td>
</tr>
<tr>
<td style="padding:4px;"><?php echo $quiz['quiz_detail'];?></td>
</tr>
<tr>
<td bgcolor="#cccccc" style="padding:4px; font-style:italic; color:#000; font-weight:bold;">By. <?=$quiz['quiz_name'];?> E-Mail : <?=$quiz['quiz_email'];?> Date : <?=$quiz['quiz_date']." ".$quiz['quiz_time'];?></td>
</tr>
</table>
<!--post ans quiz-->
<h2>ตอบคำถาม</h2>
<form action="#" method="post">
<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<td>รายละเอียด<br>
<textarea name="ans_detail" id="ans_detail" cols="70" rows="5"></textarea></td>
</tr>
<tr>
<td>ชื่อ<br><input type="text" name="ans_name" id="ans_name" class="input_text"></td>
</tr>
<tr>
<td>
<input type="submit" name="answer" id="button" value="ตกลง" class="input_submit">
<input type="reset" name="button2" id="button2" value="ยกเลิก" class="input_submit">
<input type="hidden" name="quiz_id" value="<?=$quiz_id;?>"></td>
</tr>
</table>
</form>
<h2>คำตอบล่าสุด</h2>
<?php //show board ans
$sql="select count(*) from board_ans";
$rs=mysql_query($sql);
$total_rec=mysql_result($rs,0,0);
$p_size=10;
$total_page=(int)($total_rec/$p_size);
if(($total_rec % $p_size)!=0){
$total_page++;
}
if(empty($_GET['pages'])){
$page=1;
$start=0;
}else{
$page=$_GET['pages'];
$start=$p_size*($page-1);
}
$board_ans=mysql_query("select * from board_ans where quiz_id=$quiz_id order by ans_id desc limit $start , $p_size");
$num=mysql_num_rows($board_ans);
while($row=mysql_fetch_assoc($board_ans)){
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#2F98BB" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#2F98BB" style="padding:4px; color:#FFFFFF; font-size:14px; border-radius:5px;"><strong>ตอบโดย </strong> : <?=$row['ans_name'];?> เมื่อ : <?=$row['ans_date'];?></td>
</tr>
<tr>
<td style="padding:4px;"><?php echo $row['ans_detail'];?></td>
</tr>
</table>
<hr>
<? } ?>
<?
echo "Total : ".$num." Record Page ::";
for($i=1;$i<=$total_page;$i++){
echo " <a href=index.php?page=webboard.php&pages=".$i.">[".$i."]</a> ";
}
?>
Code (PHP)
<h2>สินค้าทั้งหมด</h2>
<table align="center">
<tr>
<!------->
<?php
$i=1;
$strQuery=mysql_query("select * from product order by ProductID desc");
while($row=mysql_fetch_assoc($strQuery)){
?>
<td valign="top" style="border:1px solid #333; padding:5px;">
<table width="220" border="0" cellspacing="0" cellpadding="0" style="margin-right:15px; margin-top:30px;">
<tr>
<td valign="top">
<a href="index.php?page=product_detail.php&ProductID=<?=$row['ProductID'];?>">
<img src="uploads/product/<?=$row['Picture'];?>" width="250" title="<?=$row['ProductName'];?>">
</a></td>
</tr>
<tr>
<td style="padding-top:10px; padding-bottom:10px;">
<strong><?=$row['ProductName'];?></strong><br>
<div>ราคา <span style="color:red; font-weight:bold;"><?=number_format($row['Price']);?>.-</span> <a href="order.php?ProductID=<?=$row['ProductID'];?>">Order</a></div>
</td>
</tr>
</table>
</td>
<?php
if($i%3==0){
echo"<td></tr>";
}?>
<? $i++; } ?>
<!------->
</tr>
</table>
ขอบคุณมากครับ
ปล.จริงๆอยากอัพไฟลเว็บทั้งหมดขึ้นมาเลย แล้วแปลส่งกลับมาให้ผม ;A; อันนี้เอาอันไม่เข้าใจมากๆสุดมาวางสองอันก่อน
Tag : PHP, MySQL, CakePHP, Windows
|
|
|
|
|
|
Date :
2014-02-01 02:04:21 |
By :
uopeydel |
View :
2945 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2014-02-01 07:02:13 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาแค่ตรงคิดว่ายากๆก็ได้ครับ ;A;)
|
|
|
|
|
Date :
2014-02-01 08:09:23 |
By :
uopeydel |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2014-02-01 11:31:14 |
By :
weaned |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|