Click to See Complete Forum and Search --> : dynamic images not working correctly.


william232
10-08-2006, 11:10 PM
i have a catalog for a shopping cart catalog page which does not display the the information of each field in the database which i have is called "image" and this is what i have.


$cid=($_GET['cid']);
if($_GET['cid'])
{
$cQuery="SELECT * FROM products WHERE cid='$cid'";
$result=mysqli_query($con,$cQuery);
if(!$result)
{
echo "Error:".mysqli_error($con);
}
else
{
$count=$result->num_rows;
if($count>0)
{
while($data=$result->fetch_assoc())
{
$pid=$data['pid'];
$items[]=$data['productName'];
$images=$data['image'];
$imagesalttag=$data['imagesalttag'];
$prices[]=$data['ProductCost'];
$desc[]=$data['ProductDescription'];
}
}
else
{
echo "<br/>There is no products in the catalog,Please contact the webmaster of this store<br/>";
}
}
}


This is the line for it


echo "<tr><td><img src".$data['image']."></td>


Got,Any idea wats wrong?

NogDog
10-09-2006, 01:31 AM
echo "<tr><td><img src='".$data['image']."'></td>

william232
10-09-2006, 01:59 AM
i have tried doing that does not even work

Neoboffin
10-09-2006, 04:11 AM
You can try:
echo "<tr><td><img src=\"".$data['image']."\"></td>
Which is more or less the same, however the correct format. If that fails, then there's something wrong with your database possibly. Can you output some raw HTML here and we can have a look and see the format.

NogDog
10-09-2006, 08:21 AM
Or you may need to prepend the $data['image'] value with the absolute path or full URI to the image directory.

bokeh
10-09-2006, 12:04 PM
Which is [...] however the correct format.So what do you see as incorrect about the other method?

Neoboffin
10-09-2006, 12:49 PM
It's not wrong as in "you shouldn't code like that", except using apostrophes around image tags can cause problems if you have images with apostrophe's in as well. I don't know how the catalog is set up either so it may have apostrophes in. Highly doubt it though.

Windows blocks you from using quotes in images, so it's safer to use quotes around image tags.

bokeh
10-09-2006, 01:39 PM
Single and double quoted attributes are equally valid. Filenames shouldn't contain either.