<?
$count=0;
//-----เชื่อมฐานข้อมูล
$host="localhost";
$user="root";
$pw="1234";
$dbname="db_member";
$charset = "SET NAMES 'utf8'";
mysql_connect ($host,$user,$pw) or die ("ติดต่อhostไม่ได้");
mysql_query ($charset) or die ('Invalid query :'.mysql_error());
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
//-------------ปิด
$sql="select * from tb_member AS a, tb_scorebe AS b, tb_scoreaf AS c where a.id = b.userid and a.id = c.userid group by a.id";
$result=mysql_db_query($dbname,$sql);
while($record=mysql_fetch_array($result)) {
$count++;
echo "
<tr>
<td>$count</td>
<td>$record[name]</td>
<td>$record[today_be]</td>
<td>$record[time_be]</td>
<td>$record[score_be]</td>
<td>$record[today_af]</td>
<td>$record[time_af]</td>
<td>$record[score_af]</td>
<td><a href=\"deletemem_test.php?id_del=$record[id]\" onclick=\"return confirm(' ต้องการลบ $record[name] ออกจากระบบจริงหรือไม่ ')\">ลบ</a></td>
</tr>";
}
mysql_close();
?>
DELETE FROM `tb_member`, `tb_scorebe`, `tb_scoreaf`
USING `tb_member`
INNER JOIN `tb_scorebe`
INNER JOIN `tb_scoreaf`
WHERE `tb_member`.`id` = 'ไอดีที่จะลบ'
AND `tb_scorebe`.`user_id` = `tb_member`.`id`
AND `tb_scoreaf`.`user_id` = `tb_member`.`id`
<?
$host="localhost";
$user="root";
$pw="1234";
$dbname="db_member";
$charset = "SET NAMES 'utf8'";
mysql_connect ($host,$user,$pw) or die ("ติดต่อhostไม่ได้");
mysql_query ($charset) or die ('Invalid query :'.mysql_error());
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
//-------------
$id_del=$_GET[id_del];
include "connect2.php";
//$sql="delete from tb_member where id='$id_del' ";
$sql="
DELETE FROM `tb_member`, `tb_scorebe`, `tb_scoreaf`
USING `tb_member`
INNER JOIN `tb_scorebe`
INNER JOIN `tb_scoreaf`
WHERE `tb_member`.`id` = '$id_del'
AND `tb_scorebe`.`user_id` = `tb_member`.`id`
AND `tb_scoreaf`.`user_id` = `tb_member`.`id`
";
$result=mysql_db_query($dbname,$sql);
if ($result) {
echo "<h3><a href='mem_test.php'>ลบข้อมูลออกจากระบบเรียบร้อยแล้ว</h3>";
} else {
echo "<h3>ไม่สามารถลบข้อมูลได้ครับ</h3>";
}
mysql_close();
?>