|
|
|
การโฟสวันที่แบบ datepicker ลงฐานข้อมูลและให้เป็นแบบ dd-mm-yyyy |
|
|
|
|
|
|
|
from.php....
Code (PHP)
<form name="demoform2" method="post" action="admin.php?page=procure/procure_add2.php">
<table width="450" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="19%" height="27" class="Font"><div align="right">หัวข้อ
:</div></td>
<td width="81%"><input name="procure_content" type="text" id="procure_content" size="40"></td>
</tr>
<tr>
<td height="29" class="Font"><div align="right">วันที่ยื่นซอง:</div></td>
<td ><input type="text" id="date1" class="input-text" size="10" value=" / / " name="date1" onClick="displayDatePicker('date1')" />
-
<input type="text" id="date2" class="input-text" size="10" value=" / / " name="date2" onClick="displayDatePicker('date2')" /> </td>
</tr>
<tr>
<td height="29" class="Font"><div align="right">วันที่เปิดซอง:</div></td>
<td><input type="text" id="date3" class="input-text" size="10" value=" / / " name="date3" onClick="displayDatePicker('date3')" /></td>
</tr>
<tr>
<td class="Font"><div align="right">รายละเอียด :</div></td>
<td><textarea name="procure_detail" cols="50" rows="10" id="procure_detail"></textarea></td>
</tr>
<tr>
<td height="30" class="Font"> </td>
<td> </td>
</tr>
<tr>
<td height="30" class="Font"><div align="right">แนบไฟล์:</div></td>
<td><input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE4" value="100000">
<input name="fileupload" type="file" class="Box" id="fileupload4" size="40"></td>
</tr>
<tr>
<td height="30" class="Font"><div align="right">สถานะ:</div></td>
<td><select name="status_id" id="select">
<?
while($row=mysql_fetch_array($result)){
$status_id = $row['status_id'];
$status_name = $row['status_name'];
if($ref_status_id==$status_id){
echo "<option value='$status_id' selected>$status_name</option>";
}else{
echo "<option value='$status_id'>$status_name</option>";
}
}
?>
</select></td>
</tr>
<tr>
<td> </td>
<td><input name="Button" type="button" onClick="MM_callJS('jascript:history.go(-1)')" value="Back">
<input type="submit" name="Submit2" value="Submit"></td>
</tr>
</table>
</form></td>
</tr>
....................................................................................................
insert.php
Code (PHP)
<?
include "chksession.php";
include "connect.php";
$procure_content = $_POST[procure_content];
$procure_detail= $_POST[procure_detail];
$status_id= $_POST[status_id];
$procure_regist = substr($_POST['date1'],6,4)."-".substr($_POST['date1'],3,2)."-".substr($_POST['date1'],0,2);
$procure_start = substr($_POST['date2'],6,4)."-".substr($_POST['date2'],3,2)."-".substr($_POST['date2'],0,2);
$procure_end = substr($_POST['date3'],6,4)."-".substr($_POST['date3'],3,2)."-".substr($_POST['date3'],0,2);
$fileupload = $_FILES['fileupload'] ['tmp_name'];
$fileupload_name = $_FILES['fileupload'] ['name'];
$fileupload_size= $_FILES['fileupload'] ['size'];
$fileupload_type= $_FILES['fileupload'] ['type'];
if($procure_content=="" || $procure_detail==""){
echo "<center><h3>กรุณาข้อมูลให้ครบด้วยครับ !!<h3></center>";
exit();
}
$field ="procure_id,procure_content,procure_detail,procure_regist,procure_start,procure_end,procure_file1_name,status_id,mem_id";
$values= "'','$procure_content', '$procure_detail','','','$date',$status_id,'$sess_username'";
$result = insert($field,$values,"tb_procure");
if($fileupload){
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]) ;
if ($lastname=="rar" or $lastname=="jpg" or $lastname=="jpeg" or $lastname=="zip" or $lastname=="pdf" ){
$sql2="select max(procure_id) from tb_procure";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$filename = $row[0] . "." . $lastname;
copy($fileupload,"procure_file/".$filename);
$sql3="update tb_procure set procure_file1_name='$filename' where procure_id = '$row[0]' ";
$result3 =mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
if($result){
echo "<center><h3>บันทึกข้อมูลเรียบร้อยแล้วครับ !!<h3></center>";
}else{
echo "<center><h3>ไม่สามารถบันทึกข้อมูลได้ครับ !!<h3></center>";
}
?>
Tag : PHP, MySQL, CakePHP
|
|
|
|
|
|
Date :
2013-09-11 09:22:50 |
By :
simple |
View :
816 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยแนะนำด้วยครับ
|
|
|
|
|
Date :
2013-09-11 09:24:11 |
By :
simple |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
function printDate($date){
list($y,$m,$d)=explode("-",$date);
$y-=1957;
$tm=array("1","2","3","4","5","6","7","8","9","10","11","12");
return (int)$d."-".$tm[$m-1]."-".$y;
}
|
|
|
|
|
Date :
2013-09-11 10:57:53 |
By :
สบายดี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jQuery UI Datepicker ปฏิทินวันที่ Calendar เลือกลงใน Textbox เลือกได้ทั้ง Date/Time
|
|
|
|
|
Date :
2014-02-03 22:16:35 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|