 |
select ไม่เป็นครับ เนื่องจากที่มีผู้รู้หลายท่านมาแนะนำให้ select ออกมาก่อนแต่ก็ยังทำไม่เป็นอยู่ดีครับ |
|
 |
|
|
 |
 |
|
$total="select total from total";
$rerult=mysql_db_query($dbname, $sql);
$row=mysql_fetch_array($rerult);
|
 |
 |
 |
 |
Date :
2010-02-03 10:55:07 |
By :
onedan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนแร กwhere id_user='1,2 'มันไม่ได้แต่พอทำแบบนี้ได้
|
 |
 |
 |
 |
Date :
2010-02-03 11:01:06 |
By :
au |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?php
$hostname = "localhost"; //ชื่อโฮสต์
$user = "root"; //ชื่อผู้ใช้
$password = "root"; //รหัสผ่าน
$dbname = "holiday"; //ชื่อฐานข้อมูล
$tblname = "total"; //ชื่อตาราง
$a="20";
// เริ่มติดต่อฐานข้อมูล
mysql_connect($hostname, $user, $password) or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_query('SET CHARACTER SET utf8');
mysql_query('SET NAMES utf8');
// เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
// คำสั่ง SQL และสั่งให้ทำงาน
$total="select total from total";
$rerult=mysql_db_query($dbname, $sql);
$row=mysql_fetch_array($rerult);
$total=$row['total'];
if($total]<$a)
{$sql ="update $tblname
set total=$total+10
where id_user=1 or id_user=2
";
}
else
{$sql ="update $tblname
set total=30
where id_user=1 or id_user=2
";
}
$dbquery = mysql_db_query($dbname, $sql);
// ปิดการติดต่อฐานข้อมูล
mysql_close();
echo "<Font Size=3><B>ปรับปรุงข้อมูลข้าราชการเรียบร้อยแล้ว</B><br><br>";
?>
|
 |
 |
 |
 |
Date :
2010-02-03 11:11:52 |
By :
onedan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้ครับผม
|
 |
 |
 |
 |
Date :
2010-02-03 14:06:43 |
By :
au |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$hostname = "localhost"; //ชื่อโฮสต์
$user = "root"; //ชื่อผู้ใช้
$password = "root"; //รหัสผ่าน
$dbname = "holiday"; //ชื่อฐานข้อมูล
$tblname = "total"; //ชื่อตาราง
$a="20";
// เริ่มติดต่อฐานข้อมูล
mysql_connect($hostname, $user, $password) or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_query('SET CHARACTER SET utf8');
mysql_query('SET NAMES utf8');
// เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
// คำสั่ง SQL และสั่งให้ทำงาน
$total="select total from total";
$rerult=mysql_db_query($dbname, $total);
$row=mysql_fetch_array($rerult);
$total=$row['total'];
if($total<$a)
{$sql ="update $tblname
set total=$total+10
where id_user=1 or id_user=2
";
}
else
{$sql ="update $tblname
set total=30
where id_user=1 or id_user=2
";
}
$dbquery = mysql_db_query($dbname, $sql);
// ปิดการติดต่อฐานข้อมูล
mysql_close();
echo "<Font Size=3><B>ปรับปรุงข้อมูลข้าราชการเรียบร้อยแล้ว</B><br><br>";
?>
|
 |
 |
 |
 |
Date :
2010-02-03 14:10:40 |
By :
ความรู้เท่าหางอึ่ง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือว่ามันก็เป็นไปตามเงื่อนไขนะครับ
แต่ว่าค่า ฟิลด์ total ของ id_user='2'มันเปลี่ยนตาม id_user='1'
|
 |
 |
 |
 |
Date :
2010-02-03 14:20:01 |
By :
au |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|