BMinor8806 Posted May 27, 2009 Share Posted May 27, 2009 Hi everyone, I am in the process of finishing up my internet business where I sell electronics products. I am using PHPMyAdmin and MySQL testing off a local WAMP server. I created my pages in Dreamweaver CS3 as .php pages, and am now trying to get my data from my database and displaying on my pages. I went ahead and created a recordset (I followed a tutorial to do that). All the data displays how I want it except for the images. The data type in the image field is LongBLOB. I have been reading a lot on this subject and some people say to store the images in a folder (which they are, and the file pathway is “cooltechonline/images/webluetooth/imagename.png”) and then store the file location to that image in the database. What should I change the data type for the image field in my SQL database to when doing this, and are .png image types OK to use. Once I get this finished, my next step is to get the hyperlinks to the products (which are external) to become active within the product name text as well as the image of the product. How would I go about doing this? As you can probably tell, I’m new to this and do not have much programming background. All help is appreciated. My database is called “product” and the data is coming from the “bluetooth product” table with the following fields: “Product”, “Brand”, “Type”, ”Hyperlink”, ”Image”, ”Retail Price”, ”Our Price”. As of right now I do not have the hyperlinks ready to enter into the database, but I should have them in the next couple of days. Thanks in advance. This is my page code from Dreamweaver: <?php require_once('Connections/bluetoothproduct.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_bluetoothproduct, $bluetoothproduct); $query_Recordset1 = "SELECT * FROM `bluetooth product` ORDER BY `Our Price` DESC"; $Recordset1 = mysql_query($query_Recordset1, $bluetoothproduct) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Untitled Document</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; } --> </style> <style type="text/css"> <!-- .style2 {color: #FFFFFF} --> </style> <style type="text/css"> <!-- .style3 {color: #000000} --> </style> <!-- InstanceEndEditable --> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; } body { background-color: #000033; } --> </style> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> </head> <body> <br /> <table width="80%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr> <td><img src="Images/Banner.png" width="1000" height="200" /></td> </tr> <tr> <td bgcolor="#000000"><ul id="MenuBar1" class="MenuBarHorizontal"> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="home.php"><strong>Home</strong></a> </div> </li> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="bluetoothproducts.php"><strong>Bluetooth Products</strong></a></div> </li> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="videogameaccessories.php"><strong>Video Game Accessories</strong></a> </div> </li> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="cellphoneaccessories.php"><strong>Cell Phone Accessories</strong></a> </div> </li> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="ipodaccessories.php"><strong>iPod Accessories</strong></a> </div> </li> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="gpsproducts.php"><strong>GPS Products</strong></a> </div> </li> <li> <div align="center" style="border: 1px #000000; border-style: none none none solid;" ><a href="mailto:[email protected]"><strong>Contact Us</strong></a></div> </li> </ul> </td> </tr> <tr> <td bgcolor="#CCCCCC"><div align="center"><!-- InstanceBeginEditable name="Edit Region" --><br /> <a href="bluetoothinfo.php">Click here to learn all about Bluetooth and why you should have a Bluetooth device</a>.<br /> <br /> <table width="75%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000"> <tr> <td colspan="3" bgcolor="#000033"><div align="center" class="style1">FEATURED BLUETOOTH PRODUCTS</div></td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="center">Motorola MOTOROKR T505 In-Car Speakerphone<br /> <img src="images/webluetooth/Motorola MOTOROKR T505 Bluetooth In-Car Speakerphone.png" width="104" height="104" /><br /> While in your car, you can take and make calls hands-free.</div></td> <td bgcolor="#FFFFFF"><div align="center">Aliph Jawbone 2 Noise Assassin Bluetooth Headset<br /> <img src="images/webluetooth/Aliph Jawbone 2 Noise Assassin Wireless Bluetooth Headset (Black).png" width="104" height="104" /><br /> The Jawbone 2 Bluetooth headset seperates speech from ambient noise.</div></td> <td bgcolor="#FFFFFF"><div align="center">Motorola MOTOROKR S9 Bluetooth Stereo Headphones<br /> <img src="images/webluetooth/Motorola MOTOROKR S9 Wireless Bluetooth Headset Stereo Headphones.png" width="104" height="104" /><br /> The MOTOROKR S9 provides wireless access to music and voice calls.</div></td> </tr> </table> <br /> <strong>SELECT A BLUETOOTH PRODUCT TYPE:</strong><br /> <br /> <table width="85%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000"> <tr> <td colspan="7" bgcolor="#000033"><div align="center"><span class="style2"><strong>ALL BLUETOOTH PRODUCTS</strong></span></div></td> </tr> <tr> <td bgcolor="#999999"><div align="center"><span class="style3"><strong>Image</strong></span></div></td> <td bgcolor="#999999"><div align="center"><span class="style3"><strong>Product</strong></span></div></td> <td bgcolor="#999999"><div align="center"><span class="style3"><strong>Type</strong></span></div></td> <td bgcolor="#999999"><div align="center"><span class="style3"><strong>Retail Price</strong></span></div></td> <td bgcolor="#999999"><div align="center"><span class="style2 style3"><strong>Our Price</strong></span></div></td> </tr> <?php do { ?> <tr> <td bgcolor="#FFFFFF"><?php echo $row_Recordset1['Image']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_Recordset1['Product']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_Recordset1['Type']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_Recordset1['Retail Price']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_Recordset1['Our Price']; ?></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> <br /> <br /> <!-- InstanceEndEditable --></div></td> </tr> </table> <script type="text/javascript"> <!-- var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"}); //--> </script> </body> <!-- InstanceEnd --></html> <?php mysql_free_result($Recordset1); ?> Link to comment https://forums.phpfreaks.com/topic/159946-php-mysql-and-databases/ Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 I don't think you stated your problem very well. You should really start off by stating explicitly what the problem is, that way, we don't get lost in your speech on what you plan to do. Not that any of us really care about your business or whatever it is. Anyways, you would just upload you image to some folder and in your database table, you have a row called Image. Store the name of the image there. So say the image you uploaded is named "woot.gif" to whatever folder (doesn't matter, but you should keep it consistent), then store "woot.gif" to the column Image in your DB table. I would have the Image column set to varchar. Link to comment https://forums.phpfreaks.com/topic/159946-php-mysql-and-databases/#findComment-843615 Share on other sites More sharing options...
grissom Posted May 27, 2009 Share Posted May 27, 2009 Change the data type for the image field to VARCHAR(128) Then store in that field the value : cooltechonline/images/webluetooth/imagename.png When you come to display : 1. Dig that value out of the database, call it something, eg $foo 2. Your HTML should go something like (I've not tested this !!) <?php echo "<IMG SRC = '$foo'>"; ?> Link to comment https://forums.phpfreaks.com/topic/159946-php-mysql-and-databases/#findComment-843627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.