【发布时间】:2017-11-27 13:43:02
【问题描述】:
我想输出特定 productid 的所有图像文件。为第 1 行、第 2 行、第 3 行等输出图像路径的正确语法是什么?我找不到它了。
$sql = "SELECT *
FROM images
WHERE productid = $productid";
$select = $db->prepare($sql);
$select->execute(array());
foreach($select as $index => $rs) {
if($rs['imagepath']){
if($index == 0){
echo $imagepath[0]; // <---What is the right sytax of this?
}
}
if($rs['imagepath']){
if($index == 1){
echo $imagepath[1]; // <---and this?
}
}
if($rs['imagepath']){
if($index == 3){
echo $imagepath[2]; // <---and this?
}
}
【问题讨论】:
-
echo $rs['imagepath'];? -
列名。
-
语法是这样的
-
WHERE productid = productid将选择所有行。为什么不直接省略WHERE子句? -
看看我的更新