 |
|
คือ ผมกำลังทำเว็บครับ ผมติดปัญหาตรง การแสดง icon new ครับ
ฟังชั่นที่ผมใช้ ในการ หา ค่าวันที่ มีดังนี้ ครับ
// function เวลา calenda
function displaydate($x) {
$date_m=array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฏาคม",
"สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม");
$date_array=explode("-",$x);
$y=$date_array[0];
$m=$date_array[1]-1;
$d=$date_array[2];
$m=$date_m[$m];
$displaydate="$d $m $y";
return $displaydate;
}
อันนี้สำหรับ add ลง ดาต้าเบสครับ
$date_ques=date("Y-m-d");
include "../include/connect.php";
$sql="insert into tb_question values('','$title_ques','$detail_ques','$type_ques','$name_ques','$email_ques','$date_ques','$website_ques','','','$IPADDRESS')";
$result=mysql_db_query($dbname,$sql);
อันนี้สำหรับ โชว์ icon new ครับ
$sql="select * from tb_question order by id_ques desc limit 10";
$result=mysql_db_query($dbname,$sql);
$date_check=date("Y-m-d"); //หาวันที่ปัจจุบัน
while($record=mysql_fetch_array($result)) {
$id_ques=$record[id_ques];
$title_ques=$record[title_ques];
$detail_ques=$record[detail_ques];
$name_ques=$record[name_ques];
$email_ques=$record[email_ques];
$date_ques=$record[date_ques];
$title_ques=htmlspecialchars($title_ques);
$name_ques=htmlspecialchars($name_ques);
$detail_ques=nl2br(htmlspecialchars($detail_ques));
$date_ques=displaydate($date_ques);
//check วันที่ เพิ่ม icon new
if ($date_check==$date_ques){
$img_new="<img src="images/icon_new1.gif">";
}else {
$img_new="";
}
<table width="100%" cellspacing="2" cellpadding="0" border="0">
<tr>
<td><img src="images/bullet03.gif" /> <a href="webboard/answer_view.php?id_ques=<?=$id_ques?>" onclick="return hs.htmlExpand(this, { objectType: 'iframe' } )"><b>
<?=$title_ques?>
</b></a> โดย <font color='#990000'>
<?=$name_ques?>
</font> <font color='#0000FF'> [
<?=$date_ques?>
] <?=$img_new?></font> </td>
</tr>
</table>
แต่มันม่ายยอมแสดงครับผม ม่ายรุจาแก้งัยดี
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
3 ก.ย. 2551 10:27:47 |
By :
superman |
View :
2654 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |