Page 1 of 1

Display images in looping table

Posted: Fri Oct 22, 2004 9:30 am
by yeo_yeo2000
I am trying to show an image in a looping table. I would like to display the image connected with each ID in a field on my table. Here is my code
while($row= mysql_fetch_array($result))
{
$list .= "<tr>";
$list .= "<td>".$row["year"]."</td>";
$list .= "<td>".$row["Make"]."</td>";
$list .= "<td>".$row["spec"]."</td>";
$list .= "<td>".$row["miles"]."</td>";
$list .= "<td>".$row["price"]."</td>";
$list .= "<td>".$row["<img src="getdata.php3?id=$row["id"]"]."</td>";
$list .= "</tr>";
}

Posted: Fri Oct 22, 2004 9:38 am
by lostboy
$list .= "<td><img src="getdata.php3?id=".$row["id"]."</td>";

Posted: Fri Oct 22, 2004 9:43 am
by yeo_yeo2000
I tried that but I keep getting a parse error on that line?

Posted: Fri Oct 22, 2004 9:53 am
by lostboy
whats the error?

Posted: Fri Oct 22, 2004 9:56 am
by yeo_yeo2000
Parse error: parse error in /usr/local/psa/home/vhosts/yomac.net/httpdocs/test.php on line 31

I also tried
$list .= "<td><img src="getdata.php3?id=".$row["id"].""></td>";
But get the same error

Posted: Fri Oct 22, 2004 10:00 am
by lostboy

Code: Select all

$list .= "<td><img src='getdata.php3?id=".$row['id']."'</td>";
More use of single quotes inside the string...

Posted: Fri Oct 22, 2004 10:02 am
by yeo_yeo2000
Thats it thanks I can stop pulling my hair out now

Posted: Fri Oct 22, 2004 10:05 am
by phpScott
you could also have done

Code: Select all

<?php
$list .= "<td><img src="getdata.php3?id="".$row['id'].""></td>";
?>
by escaping the quotes that need to be there for the img src