我的問題是:如何使用PHP和具體查詢並增加圖像
我想補充另一個圖像時,圖像會保存在數據庫中,但ID爲0,它無法顯示的用戶。
數據庫:
寄宿
ID(PK)
名
地址
img_homestay
imgid(PK)
ID(FK)
名
filetyp Ë
文件大小
位置
代碼:
$id=$_GET['id'];
$path = pathinfo($_SERVER['PHP_SELF']);
for ($i = 0; $i < count ($_FILES['userfile']['name']); $i++)
{
$tmp_file = $_FILES['userfile']['tmp_name'][$i];
\t \t $filetype = $_FILES['userfile']['type'][$i];
$filesize = $_FILES['userfile']['size'][$i];
$filename = $_FILES['userfile']['name'][$i];
$destination = $path['dirname'] . '../data/' . $filename;
if (move_uploaded_file($tmp_file, $_SERVER['DOCUMENT_ROOT'] . $destination))
{
\t \t $result = mysql_query ("INSERT INTO img_homestay (id, location, filetype, filename, filesize) VALUES ('$id','$destination', '$filetype', '$filename', '$filesize') ");
}
}
echo "<script>alert(\"Your Homestay Successfully Add an Images!\")</script>";
header("Location:".$_SERVER['HTTP_REFERER']);
mysql_close($link);
<table width="322" height="29" border="0" align="right">
<tr><form action="addimg.php" method="post" enctype="multipart/form-data" name="addimg">
<th width="120" height="25" scope="row">Add Images</th>
<td width="121"><input multiple="multiple" type="file" name="userfile[]">*Limit upload to 10 images only </br><input type="submit" name="submit" id="submit" value="Submit" /></td>
</form>
</table>
檢查您是否得到id –
請顯示HTML代碼 –
顯示此字符串(3)「$ id」成功! – mira