|
 |
|
เพิ่มข้อมูลลงตารางไม่ได้ ผมเขียน php คำสั่ง sql ให้ เพิ่มข้อมูลลงในตาราง และสั่งให้โชว์ข้อมูล |
|
 |
|
|
 |
 |
|
ผมเขียน php คำสั่ง sql ให้ เพิ่มข้อมูลลงในตาราง
และสั่งให้โชว์ข้อมูล ที่จะเพิ่มด้วยอ้างตัวแปรจากฟอร์มที่กรอกข้อมูล
ก็สามารถโชว์ได้ถูกต้อง แต่ว่าข้อมูลไม่เพิ่มลงในตาราง
ตัวอย่างcode
$hostname = "localhost"; //ชื่อโฮสต์
$user = "root"; //ชื่อผู้ใช้
$password = ""; //รหัสผ่าน
$dbname = "db"; //ชื่อฐานข้อมูล
$tblname = "tb"; //ชื่อตาราง
// เริ่มติดต่อฐานข้อมูล
mysql_connect($hostname, $user, $password) or die("ติดต่อฐานข้อมูลไม่ได้");
// เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
setlocale("LC_TIME","th");
$a = strftime("%A");
$b = strftime("%d");
$c = strftime("%B");
$d = strftime("%Y")+543;
$e = date("H:i:s");
$gen_date = "วัน$a ที่ $b $c $d เวลา $e น.";
$sql = "insert into $tblname (th, fname, lname, gcode, distirbu, gen_date) values ('$th', '$fname', '$lname, '$gcode', '$distirbu, '$gen_date')";
$dbquery = mysql_db_query($dbname, $sql);
echo "<Br><Br>ลำดับที่ = <font color=red>".$th."</font>";
echo "<Br><Br>ชื่อ= <font color=red>".$fname."</font>";
echo "<Br><Br>นามสกุล= <font color=red>".$lname."</font>";
echo "<Br><Br>รหัสนักศึกษา = <font color=red>".$gcode."</font>";
echo "<Br><Br>สาขาวิชา = <font color=red>".$distirbu."</font>";
echo "<Br><Br>วันที่ลงทะเบียน = <font color=red>".$gen_date."</font>";
"<Br><Br>การลงทะเบียนเรียบร้อย";
echo "<Br><a href= register_thesis.php> กลับไปหน้าหลัก</a>";
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
28 เม.ย. 2549 10:37:52 |
By :
หยัง |
View :
3524 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$sql = "insert into $tblname (th, fname, lname, gcode, distirbu, gen_date) values ('$th', '$fname', '$lname, '$gcode', '$distirbu, '$gen_date')";
$sql = "insert into $tblname (th, fname, lname, gcode, distirbu, gen_date) values ('$th', '$fname', '$lname, '$gcode', '$distirbu', '$gen_date')";
|
 |
 |
 |
 |
Date :
28 เม.ย. 2549 15:21:11 |
By :
ปุด |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|