[英]PHP/MYSQL using while loop to get current row then output data from column 1, then proceed to do the same for the following rows
好的,我有一个名为fotf_images的表的mysql数据库,您可以猜测该表存储了位置,名称等图像信息。
现在,即时通讯正在使用以下代码为每行动态添加img标签:
$count = 0;
$currentcount = $count; //gets row by count number
while($count < $numrows)
{
echo '<img src="" width="250" height="200" class="fotfimage" vspace="2"> ';
$count++;
if($count == $numrows)
{
break;
}
}
现在,我需要做的实际上是基于当前选定的行第1列中的数据显示图像。因此,例如,如果有3行,那么我当前的代码将添加3个img标签,然后我需要添加src基于每个行的列1的字段值存储每个img标签,该列存储其位置。
任何帮助,将不胜感激。 谢谢!
我不确定我是否理解正确:每张图片的来源都存储在第一列中? 如果我做对了,也许下面的代码会为您提供帮助。
<?php
$result = mysql_query("SELECT * FROM fotf_images");
while ($row = mysql_fetch_array($result)) {
$columnId = 0;
echo '<img src="'.$row[{$columnId}].'" width="250" height="200" class="fotfimage" vspace="2">';
}
?>
像这样吗?
$my_array = mysql_fetch_row ($result)
echo '<img src="'.$my_array[1].'" width="250" height="200" class="fotfimage" vspace="2"> ';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.