-2

所以我有两个php文件第一个

  <?php
  include"db.inc.php";//database connection
  $order = "SELECT * FROM notes";
  $result = mysql_query($order);
  while ($row=mysql_fetch_array($result)){
    echo ("<tr><td>$row[Name]</td>");
    echo ("<td>$row[Comment]</td>");
    echo ("<td>$row[Timestamp]</td>");
    echo ("<td><a href=\"edit_form.php?id=$row[Timestamp]\">Edit</a></td></tr>");
  }
  ?>

第二个。

  <?php
  include "db.inc.php";//database connection

  $order = "SELECT * FROM note 

  where Timestamp='id'";
  $result = mysql_query($order);
  $row = mysql_fetch_array($result);
  ?>

第一个文件中的 is 和id=$row[Timestamp]以及Timestamp='id'";我如何让第二个文件中的 id 值等于第一个文件中的 id。谢谢

4

2 回答 2

0
  • Put the code in second file as function.
  • Include the Second file to "edit_form.php" and Call the function of Second file from "edit_form.php" passing value of $id (obtained from $_Get['id'] ).
于 2013-05-08T14:46:35.163 回答
0

$_GET在这里使用

include "db.inc.php";//database connection

$id = $_GET['id'];
$order = "SELECT * FROM note where Timestamp='$id'";

开始使用PDOORMySQLi和准备好的语句,这段代码充满了SQL Injection.

编辑

在第三个文件中使用访问变量$_POST

$id = $_POST['id']; 
$name = $_POST['name'];
于 2013-05-08T14:42:20.380 回答