ไม่สำเร็จครับ หลังจากพยายามร่วม ชม. ยังคงเป็นบัวใต้น้ำต่อไป
ผมเพิ่ม บันทัดนี้เข้าไป มีป๊อปอัพ แต่ตัวแปรไม่รับค่า
echo '<td>',"<a href=\"delete.php?id=\" , $row[id] , onclick=\"return confirm('คุณต้องการลบข้อมูลนี้ใช่หรือไม่?')\" >",'ลบ','</a>','</td>';
ตัวแปร
$row[id] ซึ่งอยู่ข้างนอกอ่านได้ พอลงไปใน a href= แล้วค่ามันหาย
ต้องแก้อย่างไรครับ
หมายเหตุ SQL
--
-- Table structure for table `players`
--
CREATE TABLE `players` (
`id` int(11) NOT NULL auto_increment,
`firstname` varchar(32) NOT NULL,
`lastname` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `players`
--
INSERT INTO `players` VALUES(1, 'Bob', 'Baker');
INSERT INTO `players` VALUES(2, 'Tim', 'Thomas');
INSERT INTO `players` VALUES(3, 'Rachel', 'Roberts');
INSERT INTO `players` VALUES(4, 'Sam', 'Smith');
------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd 
">
<html>
<head>
<title>View Records</title>
</head>
<body>
<?php
/*
VIEW.PHP
Displays all data from 'players' table
*/
// connect to the database
include('connect-db.php');
// get results from database
$result = mysql_query("SELECT * FROM players")
or die(mysql_error());
// display data in table
echo "<p><b>View All</b> | <a href='view-paginated.php?page=1'>View Paginated</a></p>";
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID</th> <th>First Name</th> <th>Last Name</th> <th></th> <th></th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['firstname'] . '</td>';
echo '<td>' . $row['lastname'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
// echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>'; // ----------------------------------------> ตรงนี้ อยากให้มีคำถามก่อน ไปหน้า delete.php ว่า จะลบจริงๆ
echo '<td>',"<a href=\"delete.php?id=\" , $row[id] , onclick=\"return confirm('คุณต้องการลบข้อมูลนี้ใช่หรือไม่?')\" >",'ลบ','</a>','</td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<p><a href="new.php">Add a new record</a></p>
</body>
</html>