Hi
I am coding an ecom site in dreamweaver, php, mysql, on my local testing server. I am using dreamweaver built-in php code for this.
I have designed the database, and have reached the stage of displaying records on the browser. I need some things done before I go further:
Images are stored in a file folder, and not uploaded to mysql db.
How do I store image information on the database? What fields do I need, and what information should be entered in each field?
How do I retrieve images from the database to display with the corresponding recordset? For e.g. show an image for each category on category display page.
Can someone help me with this? Appreciate it.
ps: please no comments about using dreamweaver code, as this is for practice for a test I am about to give.
Hello
what you normally do would be to store the name of the image, so product1.jpg thats all you store then when you create the php loop to call the other product information you like name description you also call the image put filling in the missing info like <img scr="images/<?php code here ?>" />
Many ways to do it to be honest, to display the picture that is. In dreamweaver i am unsure as i do not use most people wont as i have gathered you understand by the comment you made. But something like this can do it in PHP
PHP Code:
$query = mysql_query("SELECT * FROM img");
while($row = mysql_fetch_array($query)){
echo $row['image'];
Hand coding is simpler, but you would need to make the array contain all the information for each product like name, description, image, price ...
Hand coding is simpler, but you would need to make the array contain all the information for each product like name, description, image, price ...
I hope this helped a little
I already have the array on, and the recordset shows all the records for the 7 categories I have. I have put the image file name in the table like images/catshirt.png, but the echo command does not show the image, just the text I have typed in.
I have this code for the image <td>:
if that doesnt work as i can not remember off the top of my head might also be missing or is that if you save it as a variable hmm
Oh thankyou, that worked, though you are right the previous code gave me an error. but this worked.
I know and I have used php code for e-shops many times before, but this project I have to use dreamweaver code only. sometimes it is just so.
thanks very much.
oh, just one more thing, while browsing for this help, I learnt that we could store image information on the database, and the field has to be a BLOB type? Any help for this?
thanks
Bookmarks