|
 |
|
ช่วยดูให้หน่อยครับ มันผิดตรงไหน นำวันที่เข้าไปในฐานข้อมูล |
|
 |
|
|
 |
 |
|
ได้แล้วครับ
นำวันที่เข้าฐานข้อมูล Mysql
Form.
Code (PHP)
<?php include('member_header.php');?>
<?php
$DD=$_POST['day'];
$MM=$_POST['month'];
$YY=$_POST['year'];
$date=$YY.'-'.$MM.'-'.$DD;
?>
<form method="post" action="member_add_save.php">
<select name="YY"><OPTION value="">year</option>
<?
for ($i=2007;$i<=2015;$i++) {
echo "<option value = '$i'>$i</option>";
}
?>
</select>
เดือนที่เลือก ::::
<select name="MM" ><OPTION value="">month</option>
<?
for ($i=01;$i<=12;$i++) {
echo "<option value = '$i'>$i</option>";
}
?>
</select>
วันที่เลือก:::
<select name="DD" ><OPTION value="">date</option>
<?
for ($i=01;$i<=31;$i++) {
echo "<option value = '$i'>$i</option>";
}
?>
</select>
<input type="submit" />
</form>
<?php include('member_footer.php');?>
Save.
Code (PHP)
<html>
<head>
<title></title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("my");
$strSQL ="INSERT INTO calendar(dates) VALUES('".date("Y-m-d")."')";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "บันทึกเรียบร้อย";
}
else
{
echo "ไม่สามารถบันทึกได้ [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-05-16 09:26:12 |
By :
พัช |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Form
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<form method="post" action="member_add_save.php.php">
<select name="year"><OPTION value="">year</option>
<?
for ($i=2007;$i<=2015;$i++) {
echo "<option value = '$i'>$i</option>";
}
?>
</select>
วัน::
<select name="month" ><OPTION value="">month</option>
<?
for ($i=01;$i<=12;$i++) {
echo "<option value = '$i'>$i</option>";
}
?>
</select>
เดือน::
<select name="date" ><OPTION value="">date</option>
<?
for ($i=01;$i<=31;$i++) {
echo "<option value = '$i'>$i</option>";
}
?>
</select>
<input type="submit" />
</form>
Save
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("my");
if ($_POST['date'] && $month=$_POST['month'] && $year !="")
{
$dd=$_POST['date'];
$mm=$_POST['month'];
$yy=$_POST['year'];
$dates=$yy.'-'.$mm.'-'.$dd;//ตัวแปรเก็บวันที่ครับ
}
$strSQL = "INSERT INTO calendar(date)value('$dates')";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "บันทึกเรียบร้อย";
}
else
{
echo "ไม่สามารถบันทึกได้";
}
mysql_close($objConnect);
?>
|
 |
 |
 |
 |
Date :
2011-05-16 09:27:10 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|