PHP?mysql的??

WBOY
WBOYOriginal
2016-06-23 14:20:511324browse

如?


想要在??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}?除
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:curl 上传Next article:求助,json_decode含gbk字串