|
 |
|
สอบถามเรื่องดึงข้อมูลจากSQL มาโชบนหน้าเว็บและก็โค้ดลบข้อมูลในsql หน่อยครับ |
|
 |
|
|
 |
 |
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor="#e1e1e1"><b>a1</b></td>
<td bgcolor="#e1e1e1"><b>a2</b></td>
<td bgcolor="#e1e1e1"><b>ลบ</b></td>
</tr>
<?
include("dbconfig.php");
$number=1;
$sql="select id,name from resong order by id";
$result=mysql_db_query("$dbname",$sql);
while ($r=mysql_fetch_array($result)){
$id=$r[id];
$name=$r[name];
echo "
<tr>
<td>$number</td>
<td>$name</td>
<td><a href='delete.php?resong=$id'
onclick=\"return confirm('คุณแน่นใจหรือไม่ ?')\">ลบ</a></td>
</tr>";
$number++;
}
?>
</table>
</body>
</html>
อันนี้ที่ผมเขียนอะครับเข้าไปแล้วแต่มันไม่ดึงข้อมูลมาให้เป้นเพราะอะไรหลอครับ
|
ประวัติการแก้ไข 2011-04-07 06:25:58
 |
 |
 |
 |
Date :
2011-04-06 19:50:19 |
By :
thannam001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2011-04-06 20:01:16 |
By :
thannam001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โชได้แล้วแต่มันลบไม่ได้ใครที่มีความสามารถช่วยที่ครับ...
ผมไม่รุ้มันผิดตรงไหนมันขึ้นข้อความลบข้มูลไปแล้วแต่ข้อมูลยังอยู่ ใครรู้ตอบผมที่.. ผมพึ่งหัดเล่นอะครับ
โค้ด index.php
Code (PHP)
<htrml>
<title></title>
<head>
<META http-equiv="Content-Type" content="text/html; charset=tis-620" >
<style type="text/css">
<!--
body {
font : 0.9em verdana,geneva, Arial, helvetica, sans-serif;
background-color: #fff;
background-position:center;
color: #000000;
background-image: url();
background-repeat:no-repeat
}
</style>
</head>
<body>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td align="center" bgcolor="#e1e1e1"><b>a1</b></td>
<td align="center" bgcolor="#e1e1e1"><b>a2</b></td>
<td align="center" bgcolor="#e1e1e1"><b>a3</b></td>
<td align="center" bgcolor="#e1e1e1"><b>a4</b></td>
<td bgcolor="#e1e1e1"><b>ลบ</b></td>
</tr>
<?
include("dbconfig.php");
$result = mysql_query("select id,name,song,singer from resong order by id");
mysql_query('SET CHARACTER SET tis620');
while ($r=mysql_fetch_array($result)){
$id=$r[id];
$name=$r[name];
$song=$r[song];
$singer=$r[singer];
echo "
<tr>
<td>$id</td>
<td>$name</td>
<td>$song</td>
<td>$singer</td>
<td><a href='delete.php?resong=$id'
onclick=\"return confirm('คุณแน่นใจหรือไม่ ?')\">ลบ</a></td>
</tr>";
$number++;
}
?>
</table>
</body>
</html>
ส่วนอันนี้ delete.php
Code (PHP)
<htrml>
<title>ลบข้อมูล</title>
<head>
<META http-equiv="Content-Type" content="text/html; charset=tis-620">
</head>
<body>
<?
$resong=$_GET['resong'];
include "dbconfig.php";
$sql="delete from resong where id=$resong";
mysql_db_query($dbname,$sql);
echo "<h2><a href='show.php'>ลบข้อมูลเรียบร้อยแล้วครับ</a></h2>";
?>
</body>
</html>
|
ประวัติการแก้ไข 2011-04-07 06:25:31
 |
 |
 |
 |
Date :
2011-04-06 21:45:05 |
By :
thannam001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|