i want to retrieve the information from database to display a product pictures. Database Information Table name : product Column name : prod_img_url Information inside the column : pic1.jpg,pic2.jpg,pic3.jpg PHP: Image display ( i only want display 1 result for "pic1.jpg") <img src="/localhost/images/<?php echo $row['prod_img_url']"?> PHP: How to code for only take the first picture address (pic1.jpg) and ignored other?Please help Urgent. Thx
Erm....the database column "prod_image_url" contain "pic1.jpg,pic2.jpg,pic3.jpg" inside because it can insert many picture inside so how i can get the first 1?How to use the where clause, i do not think can use WHERE because the column "prod_image_url" maybe contain information with other name "1.jpg,2.jpg,3.jpg,4.jpg".
<? $hostName = "localhost"; // Address of the database server $databaseName = "try"; // Name of the database $dbusername = "root"; // User name $dbpassword = ""; // Database password $db=mysql_connect("$hostName","$dbusername","$dbpassword") or die('Error, Could not connect to the database'); mysql_select_db("$databaseName"); $result=mysql_query("SELECT prod_img_url FROM product"); while($row=mysql_fetch_array($result)) { $rawimagename=$row['prod_img_url']; $imagename=explode(',',$rawimagename); foreach($imagename as $key => $value) { ?> <img src="<? echo $value ?>" alt="<? echo $value ?>"> <? } } ?> Check above code....