checkmodem12 Posted July 11, 2006 Share Posted July 11, 2006 what i'm trying to do is display an item description with corresponding picture. right now i just have this code which displays all the items in "crafts" field. how would i display the picture? would i need to put the pictures in a separate database then call it or some say to just put a link to the picture but i imagine this being difficult if the description loops. please help. <?$username="";$password="";$database="";mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");$query="SELECT * FROM table WHERE classification='crafts'";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();$i=0;while ($i < $num) {$id=mysql_result($result,$i,"id");$description=mysql_result($result,$i,"description");$price=mysql_result($result,$i,"price");$classification=mysql_result($result,$i,"classification");?> Quote Link to comment https://forums.phpfreaks.com/topic/14249-need-to-display-item-description-with-picture/ Share on other sites More sharing options...
Prismatic Posted July 11, 2006 Share Posted July 11, 2006 In your table "table" create a field named "imageurl", this will contain the URL to the picture you wish to display, example: http://www.yoursite.com/images/image.jpgThis should get you going in the right direction...[code]<?php$username="";$password="";$database="";$link = @mysql_connect("localhost", $username, $password); if (!$link){ die( "Unable to connect to MySQL Server!");}$db_selected = mysql_select_db($database, $link);if (!$db_selected){ die( "Unable to select database");}$result = mysql_query("SELECT * FROM table WHERE classification = 'crafts'");while($ResultArr = mysql_fetch_array($result)){ $id = $ResultArr['id']; $description = $ResultArr['description']; $price = $ResultArr['price']; $classification = $ResultArr['classification']; $imageurl = $ResultArr['imageurl']; echo "<center><img src='". $imageurl ."' alt='". $description ."'><br>". $description ."<br>Price: ". $price ."</center><hr>";}mysql_close();?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14249-need-to-display-item-description-with-picture/#findComment-55960 Share on other sites More sharing options...
checkmodem12 Posted July 12, 2006 Author Share Posted July 12, 2006 thanks that helps a lot. let me try to see how it will look. thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/14249-need-to-display-item-description-with-picture/#findComment-56596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.