如?
想要在??mysql_result.php??中加入?除使用者??密?的功能,?他改?如下?,?他能???[?除]
??超??,就能?除掉那一行的值
??各位要怎?做呢??
以下是mysql_result.php的源?
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>?示所有??</title> </head> <body> <h1 align="CENTER">??密??示表</h1> <?php require_once("mysql.php"); $link = create_connection(); $sql = "SELECT no AS '??',username AS '??',password AS '密?' FROM root"; $result = execute_sql("os", $sql, $link); echo "<table border='1' align='center'><tr align='center'>"; for ($i = 0; $i < mysql_num_fields($result); $i++) echo "<td>" . mysql_fetch_field($result, $i)->name. "</td>"; echo "</tr>"; for ($j = 0; $j < mysql_num_rows($result); $j++) { echo "<tr>"; for ($k = 0; $k < mysql_num_fields($result); $k++) echo "<td>" . mysql_result($result, $j, $k) . "</td>"; echo "</tr>"; } echo "</table>" ; mysql_free_result($result); mysql_close($link); ?> </body></html>
<?phpfunction create_connection(){$link = mysql_connect("localhost","root","")or die("?法?接" . mysql_error());mysql_query("SET NAMES utf8");return $link;}function execute_sql($database,$sql,$link){$db_selected = mysql_select_db($database,$link)or die("?法??" . mysql_error($link));$result = mysql_query($sql,$link);return $result;}?>
javascript+ajax实现
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>?示所有??</title> </head> <body> <h1 align="CENTER">??密??示表</h1> <?php require_once("mysql.php"); $link = create_connection(); if(isset($_GET['del'])) { $sql = "delete from root ehere no=$_GET[del]"; $result = execute_sql("os", $sql, $link); } $sql = "SELECT no AS '??',username AS '??',password AS '密?' FROM root"; $result = execute_sql("os", $sql, $link); echo "<table border='1' align='center'><tr align='center'>"; for ($i = 0; $i < mysql_num_fields($result); $i++) echo "<td>" . mysql_fetch_field($result, $i)->name. "</td>"; echo "<td>操作</td>"; echo "</tr>"; for ($j = 0; $j < mysql_num_rows($result); $j++) { echo "<tr>"; for ($k = 0; $k < mysql_num_fields($result); $k++) echo "<td>" . mysql_result($result, $j, $k) . "</td>"; echo "<td><a = href=?del=" . mysql_result($result, $j, 0) . "</td>"; echo "</tr>"; } echo "</table>" ; mysql_free_result($result); mysql_close($link); ?> </body></html>
??已找到解?方法:)
//以下是重新做的mysql_result.php源?
//mysql_result.php
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
?? | 使用者?? | 密? | 操作 |
{$no} | ";{$username} | ";{$password} | ";?除 | ";