因此,我正在爲社交網絡創建照片庫。目前我正在創建一個預上傳頁面。我設置了5個字段來輸入帶有適當字幕的圖像。但是,我的主要問題是填充下拉列表。下拉列表應該包含來自數據庫(photo_category)的照片類別,但下拉列表是空的。關於我要去哪裏的任何建議都是錯誤的?從SQL數據庫填充下拉列表
編輯:現在我已經通過添加category_id和category_name來更改$ row中的內容,但它現在說「解析錯誤:語法錯誤,意外的T_ENCAPSED_AND_WHITESPACE,期望T_STRING或T_VARIABLE或T_NUM_STRING在第16行」。在quesion線前面是2星。
<?php
require 'configphot.inc.php';
$_photo_upload_fields='';
$count=1;
$nofields=(isset($_GET['number_of_fields']))?
(int) ($_GET['number_of_fields']):5;
$result = mysqli_query($link,"SELECT category_id, category_name FROM photo_category");
while($row=mysqli_fetch_array($result)){
$_photo_category_list .= <<<__HTML_END
**<option value="$row['category_id']">$row['category_name']**</option>n
__HTML_END;
}
mysqli_free_result($result);
while($counter<=$nofields)
{
$photo_upload_fields .= <<<__HTML_END
<tr><td>
Photo{$counter}:
<input name = "photo_filename[]" type= "file" />
</td></tr>
<tr><td>
Caption:
<textarea name ="photo_caption[]" cols = "30" rows ="1"></textarea>
</td></tr>
__HTML_END;
$counter++;
}
//End output
echo <<<__HTML_END
<html>
<head>
<title> Upload photos here</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post" name= "upload_form">
<table width="90%" border="0" align="center" style="width: 90%;">
<tr>
<td>Select Category
<select name="category">
$photo_category_list</select></td>
</tr>
<!image fields here -->
$photo_upload_fields
<tr><td>
<input type ="submit" name="submit" value= "Add photos">
</td></tr>
</table>
</form>
</body>
</html>
__HTML_END;
?>
我將其更改爲「$ result = mysqli_query($ link,'SELECT category_id,category_name FROM photo_category');」但不幸的是,還沒有出現。 – Anthony 2015-02-24 19:14:21