สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network
Moderators: mindphp, ผู้ดูแลกระดาน
-
mubank
Post
by mubank »
อันนี้เป็นหน้า index ของผมอะคับแต่ผมทำหน้าแก้ไขไหมได้อะคับช่วยหน่อยครับผม
Code: Select all
<body>
<?php
include("header.inc.html");
?>
<td><a href="insert_db.php" onClick="return confirm('คุณต้องการเพิ่มข้อมูลหรือไหม')"><span class="red"><strong><center> เพิ่มข้อมูล</center></strong></span></a></td>
<table align="center" width="200" border="1">
<tr>
<td bgcolor="#000000"><div style="font-size:16pt; color:white;"align="center">คำ</div></td>
<td bgcolor="#000000"><div style="font-size:16pt; color:white;" align="center">แก้ไข</div></td>
<td bgcolor="#000000"><div style="font-size:16pt; color:white;" align="center">ลบ</div></td>
</tr>
<?php
require_once "config_db.php";
while($data = mysql_fetch_array($dbquery))
{
?>
<tr>
<td><div align="center"><?=$data['censor_b']?></div></td>
<td align="center"><a href="edit.php?id=<?=$data['censor_b']?>" onClick="return confirm('คุณต้องการแก้ไขข้อมูลหรือไหม')?')"><span class="red"><strong>แก้ไข</strong></span></a></td>
<td align="center"><a href="delete.php?id=<?=$data['censor_b']?>" onClick="return confirm('คุณต้องการลบข้อมูลหรือไหม') ?')"><span class="red"><strong>ลบ</strong></span></a></td>
</tr>
<?
}
?>
</table>
</body>
ขอบคุณล่วงหน้าครับผม
-
touleg
- PHP Super Member

- Posts: 480
- Joined: 25/01/2010 11:57 pm
-
Contact:
Post
by touleg »
แก้ไขอะไร
-
mubank
Post
by mubank »
คือ เพิ่มลบแก้ไขข้อมูลอะคับ
ทีนี้ผมทำ ลบ กับ เพิ่มข้อมูลได้แล้วอะคับ
เหลือแก้ไขทำไม่ได้สักทีคับ มันไม่ยอมแก้ค่าให้อะคับ
ฐานข้อมูล ชื่อ censor
ตาราง ชื่อ censor_ban ข้างในมี censor_b อันเดียว
-
mubank
Post
by mubank »
Code: Select all
<?
require_once "config_db.php";
if($_REQUEST['id'] != "")
{
$qdelete="update from censor_ban where censor_b ='$id'";
@mysql_query($qdelete);
?>
<form name="form1" method="post" action="edit.php">
<p>แก้ไขข้อมูล<br>
อันนี้มันเป็นโค้ดที่ผมทำแก้มั่วไปหมดแล้วอะครับ ช่วยแนะนำทางสว่างให้หน่อยคับ
code
<input type="text" name="code" value="<?=$data['id']?>">
<br>
<br>
<input type="submit" name="Submit" value="บันทึกข้อมูล">
</p>
</form>
<?
require_once "config_db.php";
$sql="update censor_ban where censor_b ='$id'";
mysql_close();
?>
-
mubank
Post
by mubank »
ช่วยชี้ทางสว่างทีคับ
-
touleg
- PHP Super Member

- Posts: 480
- Joined: 25/01/2010 11:57 pm
-
Contact:
Post
by touleg »
ฐานข้อมูลควรจะมี field อย่างน้อย 2 field ขึ้นไปนะครับ field 1 เอาไว้เป็น primary key อีก field 1 เป็นค่าที่เก็บ
ถ้าไม่เปลี่ยนก็ใช้คำสั่งตามนี้
Code: Select all
$qdelete="update set censor_b='ค่าใหม่' from censor_ban where censor_b ='ค่าเก่า'";
-
mubank
Post
by mubank »
ขอบคุณคับ เด่วลองดูก่อนนะคับ
-
dexjanghan
- PHP Sr. Member

- Posts: 68
- Joined: 02/03/2011 5:36 pm
Post
by dexjanghan »
Primary Key มันมีในหน้า Form มั๊ยล่ะครับ
เอาขั้นมาแสดงด้วย ไม่ก็ใช้คำสั่ง ซ่อนไว้ก็ได้ครับ
เพื่อที่ว่าเวลาคลิกแล้ว Primary Key จะได้ถูกส่งไปด้วย
-
-
- 0 Replies
- 5416 Views
-
Last post by จันนุสรณ์ ดีแก่
27/11/2018 11:12 am
-
-
- 4 Replies
- 84796 Views
-
Last post by mindphp
21/04/2017 2:48 am
-
-
- 1 Replies
- 1078 Views
-
Last post by thatsawan
18/01/2016 9:31 pm
-
-
- 0 Replies
- 584 Views
-
Last post by yodmanoot
13/08/2015 2:27 pm
-
-
- 5 Replies
- 1066 Views
-
Last post by The_JaYz
20/08/2015 9:28 am
-
-
- 0 Replies
- 148 Views
-
Last post by mindphp
15/12/2020 8:07 pm
-
-
- 0 Replies
- 2912 Views
-
Last post by jutikul1012
03/02/2020 11:02 am
Users browsing this forum: Google Adsense [Bot] and 13 guests