www.webdeveloper.com
Results 1 to 10 of 10

Thread: images for e-shop

  1. #1
    Join Date
    Dec 2002
    Posts
    213

    Question images for e-shop

    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.
    1. How do I store image information on the database? What fields do I need, and what information should be entered in each field?
    2. 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.

    Thanks

  2. #2
    Join Date
    Feb 2007
    Location
    Wolverhampton
    Posts
    96
    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 ...

    I hope this helped a little
    My name is Tom Bangham i am owner of a web developer company called Phoenix Web Solutions.

  3. #3
    Join Date
    Dec 2002
    Posts
    213

    Question missing code

    Quote Originally Posted by mrtom100 View Post
    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 ...

    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>:
    PHP Code:
    <?php echo "<img src=" $row_catsview['cat_image_name']" />";?>
    I think I am missing something in the above code.
    Thanks

  4. #4
    Join Date
    Feb 2007
    Location
    Wolverhampton
    Posts
    96
    <?php echo "<img src=" $row_catsview['cat_image_name']" />";?>
    Yes you have escaped the " there are two ways of doing this :


    echo "<img scr=\"banner.gif\" height=\"80\" width=\"468\" alt=\"Click Here\">";

    echo '<img scr="banner.gif" height="80" width="468" alt="Click Here">';

    so try it as

    <?php echo '<img src=" $row_catsview['cat_image_name']" />';?>
    My name is Tom Bangham i am owner of a web developer company called Phoenix Web Solutions.

  5. #5
    Join Date
    Feb 2007
    Location
    Wolverhampton
    Posts
    96
    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

    <?php $image=$row_catsview['cat_image_name']; echo "<img src=". $image." />";?>
    My name is Tom Bangham i am owner of a web developer company called Phoenix Web Solutions.

  6. #6
    Join Date
    Dec 2002
    Posts
    213

    Thumbs up it worked!

    Quote Originally Posted by mrtom100 View Post
    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.

  7. #7
    Join Date
    Dec 2002
    Posts
    213
    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

  8. #8
    Join Date
    Feb 2007
    Location
    Wolverhampton
    Posts
    96
    Not a problem after i sent it i though hang on lol... glad its sorted good luck
    My name is Tom Bangham i am owner of a web developer company called Phoenix Web Solutions.

  9. #9
    Join Date
    Feb 2007
    Location
    Wolverhampton
    Posts
    96
    My name is Tom Bangham i am owner of a web developer company called Phoenix Web Solutions.

  10. #10
    Join Date
    Dec 2002
    Posts
    213
    thnx, i will surely check it out. I am learning a lot of things, designing this way, even if the code is stuffed up.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles