SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Location
    New York, NY
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question [PHP]//Help:[/PHP] Displaying Images in an Array Loop

    Hi!

    I am trying to retrieve different products with their respective attributes from a MySql database table where the different fields are:

    product_id
    product_name
    product_pic (type: TEXT) - Need help here! (See Below)
    product_price
    product_briefdesc
    product_category
    product_status

    I would like to display all of these values for each product from the table that has a product_category value=8 AND a product_status=2 .

    So far, the loop is displaying the value of all of the products just like I wanted it. However, it's not showing the PICTURE which has been uploaded in a separate directory I setup on the server. I guess the question would be: "How do I access the picture filename located in a different directory while processing a loop.

    I am new to PHP, so I don't know what's wrong with displaying a picture filename like "product_picture = NoPic.jpg" when its content is in a directory called "images"?

    What am I doing wrong?

    Thank You LifeSaver - WhoEver You Are!

    Here is the LOOP code I am currently using:

    PHP Code:

    <table>
    <?php

    // Database Connection is Fine.

    // SQL Query (seems to be fine!) as follows: 
    $productselect= @mysql_query("SELECT product_name, 
                         product_price, product_pic,
                         product_briefdesc,
                         product_id FROM Products 
                         WHERE product_category=8 
                         AND product_status=2"
    );  


    // To begin loop displaying product details:
    while ($product mysql_fetch_array($productselect)) 

    $ProductName  $product["product_name"]; 
    $ProductPrice  $product["product_price"];  
    $ProductPic  = ($product["product_pic"]);
    $ProductBrief  htmlspecialchars($product["product_briefdesc"]); 
    $ProductID  $product["product_id"]; 

    // I mostly need help with the PICTURE LINE ONLY!
    // Variable "$ProductPic" , Field Name "product_pic" 
    // Location "images" directory.
    // EVERY THING ELSE WORKS!

    echo("<tr> ".
         
    "<td width='22%'> ".
         
    "<a href='product.php?pid="$ProductID .">".
         
    "<img src='images/".$ProductPic."' width=75 border=0>"//Problem is HERE! No Picture or X-Box Displayed.
         
    "</a> ".
         
    "</td>".
         
    "<td width='55%'> "
         
    "<a href='product.php?pid="$ProductID ."'>".
         
    " <b>"$ProductName ." </b> ".
         
    "</a>".
         
    " <br>".
         
    "<b> <font size='2' color='darkgreen'>Retail Price: ".
         
    "<s>$"$ProductRetail"</s>".
         
    "</font> &nbsp; / &nbsp; <font size='2' color='#CC0000'>Our Price:"
         
    " $".  $ProductPrice"</font> </b> ".
         
    "<br>"$ProductBrief ."<br>".
         
    "<a href='product.php?pid="$ProductID ."'>".
         
    " More Info </a> ".
         
    "</td>".
         
    "</tr>");
    }
    ?>
    </table>
    Live life to the fullest and have fun in the process!

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are missing a one single quote... just like in your identical thread I took time out of my life to examine.
    http://www.sitepointforums.com/showt...?postid=506008

    Big frown.

    <edit> Not really a big frown... more of a big roll eyes .
    Last edited by samsm; Jul 23, 2002 at 20:07.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

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