首頁 > 後端開發 > php教程 > PHP?mysql的??

PHP?mysql的??

WBOY
發布: 2016-06-23 14:20:51
原創
1321 人瀏覽過

如?


想要在??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>
登入後複製



然後?有mysql.php??必要?案的源?
<?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;}?>
登入後複製





??要如何修改mysql_result.php ??成需要的效果呢? ??


回复讨论(解决方案)

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">




?料列表
<script> <br /> function DeleteNo(no) <br /> { <br /> if (confirm("?除本?料?")) <br /> location.href = "del.php?no=" + no; <br /> } <br /> </script>




require_once("mysql.php");
$link = create_connection();

echo "";
echo "";
$sql = "SELECT no AS 'no',username AS 'username',password AS 'password' FROM root";
$result = execute_sql("os",$sql,$link);

while($row = mysql_fetch_array($result))
{
?>

$no = $row['no'];
$username = $row['username'];
$password = $row['password'];

echo "";
echo "";
echo "";
echo "";
echo "";
echo "";




?>





}
?>





然後??no值?到del.php ?行?料?值的?除?理:

//del.php

  require_once("mysql.php");
  $link = create_connection();
  $no = $_GET["no"];

//$sql = "DELETE FROM root WHERE no = $no";

//$result = execute_sql("os",$sql,$link);

echo "<script>alert('?? $no 的?料已?除')</script>";


?>
?? 使用者?? 密? 操作
{$no}{$username}{$password}?除
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板