因此,我正在为社交网络创建照片库。目前我正在创建一个预上传页面。我设置了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