jayjay1234 Posted March 26, 2012 Share Posted March 26, 2012 Hi I am creating an e commerce website and I have been using a php dummies book to help me as I am a beginner. I am creating an e commerce website and I have created a page which consists of radio buttons where a user will be able to choose what type of shoe they would like to view. Once they have chosen the radio button and then clicked onto the show me button the type of shoe shown should be the same as the type they have chosen but no shoes are showing on the webpage. I am unsure if i have not entered the format correct in the image section of the database. Here is the code which i have created so far: /* Select shoes the type specified*/ $query = "SELECT * FROM products WHERE prod_type=\"{$_POST['interest']}\""; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); /* Display results in a table */ echo "<table cellspacing='10' border='1' cellpadding='87' width='100%'>"; echo "<tr><td colspan='5' style='text-align: right'> Click on any picture to see a larger version. <hr /></td></tr>\n"; while($row = mysqli_fetch_assoc($result)) { $f_price = number_format($row['product_price'],2); /* display row for each shoe */ echo "<tr>\n"; echo " <td>{$row['product_id']}</td>\n"; echo " <td style='font-weight: bold; font-size: 1.1em'>{$row['product_name']}</td>\n"; echo " <td>{$row['product_description']}</td>\n"; echo "<tr><td colspan='5'><hr /></td></tr>\n"; } echo "</table>\n"; echo "<div style='text-align: center'> <a href='shoes_list.php'> <h3>See more shoes</h3></a></div>"; ?> in my database the product_image column the field just contains the file name e.g: heels.jpg. please can anyone help me to get the images displayed.. thank you Quote Link to comment https://forums.phpfreaks.com/topic/259762-images-are-not-uploading-onto-webpage-from-phpmyadmin/ Share on other sites More sharing options...
Psycho Posted March 26, 2012 Share Posted March 26, 2012 I don't see anyhing in your output that would generate an image in the output. Typically, the image path/name of the image is stored in the database and then when generating the output you would do something such as echo "<img str='{$row['product_image']}' /> But, again, I don't even see a field referenced in the output that would seem to be an image. Also, you *can* store the actual image data in the DB and dynamically create the images, but that's a little more complicated and not what I think you want at this time. So, what is the field in the DB where you are storing the image info and what do those contents contain? Quote Link to comment https://forums.phpfreaks.com/topic/259762-images-are-not-uploading-onto-webpage-from-phpmyadmin/#findComment-1331336 Share on other sites More sharing options...
smerny Posted March 26, 2012 Share Posted March 26, 2012 ...<img str='{$row['product_image']}' />... he means img src - typo Quote Link to comment https://forums.phpfreaks.com/topic/259762-images-are-not-uploading-onto-webpage-from-phpmyadmin/#findComment-1331338 Share on other sites More sharing options...
jayjay1234 Posted March 26, 2012 Author Share Posted March 26, 2012 here is my revisted code: <?php include("connect_db.inc"); $cxn = mysqli_connect($host,$user,$password,$dbname) or die ("couldn't connect to server"); /* Select shoes the type specified*/ $query = "SELECT * FROM products WHERE prod_type=\"{$_POST['interest']}\""; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); /* Display results in a table */ echo "<table cellspacing='10' border='1' cellpadding='87' width='100%'>"; echo "<tr><td colspan='5' style='text-align: right'> Click on any picture to see a larger version. <hr /></td></tr>\n"; while($row = mysqli_fetch_assoc($result)) { $f_price = number_format($row['product_price'],2); /* check whether shoes comes in colors */ $query = "SELECT * FROM Colour WHERE product_name='{$row['product_name']}'"; $result2 = mysqli_query($cxn,$query) or die(mysqli_error($cxn)); $ncolors = mysqli_num_rows($result2); /* display row for each shoe */ echo "<tr>\n"; echo " <td>{$row['product_id']}</td>\n"; echo " <td style='font-weight: bold; font-size: 1.1em'>{$row['product_name']}</td>\n"; echo " <td>{$row['product_description']}</td>\n"; /* display picture if shoe does not come in colours */ if( $ncolors <= 1 ) { echo "<td><a href='/images/{$row['product_image']}' border='0'> <img src='/images/{$row['product_image']}' border='0' width='100' height='80' /> </a></td>\n"; } echo "<td align='center'>\$$product_price</td>\n </tr>\n"; /* display row for each colour */ if($ncolors > 1 ) { while($row2 = mysqli_fetch_assoc($result2)) { echo "<tr><td colspan=2> </td> <td>{$row2['product_colour']}</td> <td><a href='/images/{$row2['product_image']}' border='0'> <img src='/images/{$row2['product_image']}' border='0' width='100' height='80' /></a></td>\n"; } } echo "<tr><td colspan='5'><hr /></td></tr>\n"; } echo "</table>\n"; echo "<div style='text-align: center'> <a href='shoes_list.php'> <h3>Display more shoes</h3></a></div>"; ?> im not sure if the <a href..... link to my image is correct im not sure how to format it. my image directory is: C:\inetpub\wwwroot\shop\images Quote Link to comment https://forums.phpfreaks.com/topic/259762-images-are-not-uploading-onto-webpage-from-phpmyadmin/#findComment-1331339 Share on other sites More sharing options...
jcbones Posted March 26, 2012 Share Posted March 26, 2012 You can use either absolute file paths or relative file paths. Example: <?php echo "<img src=\"http://www.mysite.com/shop/images/{$row['product_image']}\" />"; //absolute path. echo "<img src=\"shop/images/{$row['product_image']}\" />"; //relative path. Quote Link to comment https://forums.phpfreaks.com/topic/259762-images-are-not-uploading-onto-webpage-from-phpmyadmin/#findComment-1331350 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.