2011-11-01 62 views
-1

首先,我得到了一個數據庫,其中我標記了不同內容的不同ID。然而,我也做了一個評論框,其中我的評論都是由id = 1,2,3 ...編號的,所以無論何時提交評論,都可以將其鏈接回我之前得到的正確標識(不是評論框ID),即如果我輸入www.example.com/synopsis?id=1,我會回到那裏。但是,我有一個鏈接到reload.php文件的delete.php文件,從而重新加載頁面。由此看來,它無法回到簡介?ID = 1,而不是它只是梗概?ID =位置標題語法錯誤

這裏是我提交評論按鈕

<form action="synopsis.php?id=<?php $id =$_GET["id"]; echo $id; ?>" method="POST"> 

這個代碼工作。

這裏是reload.php文件,它不工作,我希望它是回梗概?ID = 1次,每次我打刪除

<?php 
$id=$_GET['id']; 
$link = mysql_connect("localhost", "root", ""); 
$refresh = mysql_query("SELECT id FROM dvd where id=$id",$link); 
$row = mysql_fetch_assoc($result); 
header("Location:synopsis.php?id=<?php $id =$_GET["id"]; echo $id; ?>"); 
?> 

請幫

回答

0

正確的字符串串聯:

header("Location:synopsis.php?id=" . $id); 
0

你已經設置的$ id變量,則不需要再次設定

$id=$_GET['id']; 
$link = mysql_connect("localhost", "root", ""); 
$refresh = mysql_query("SELECT id FROM dvd where id=$id",$link); 
$row = mysql_fetch_assoc($result); 
header("Location:synopsis.php?id=". $id); 
0

重複的quotes syntax errors?

不管怎麼說:

<?php 
$id=$_GET['id']; 
$link = mysql_connect("localhost", "root", ""); 
$refresh = mysql_query("SELECT id FROM dvd where id=$id",$link); 
$row = mysql_fetch_assoc($result); 
header("Location:synopsis.php?id=".$_GET['id']); 
?> 
0

<?php用於從HTML切換到PHP模式,但在此代碼,在PHP模式是已經:

header("Location:synopsis.php?id=<?php $id =$_GET["id"]; echo $id; ?>"); 

當你建立一個新的查詢條紋時逃避變量也是一個好習慣ng:

header("Location: synopsis.php?" . http_build_query(array(
    'id' => $_GET['id'], 
)));