Results 1 to 8 of 8
  1. #1
    Newbie
    Join Date
    April 24th, 2005
    Posts
    14
    PHP Product image troubles
    i have a mysql database and i am using php to display the query results in a table to make a product browsing page. I have the html of the product image and am having troubles displaying the image, it just lists the html of the img and i can't figure how to make it work with the <img src= tag. here is the snippet of code i need to be able to display the image in

    echo '<td width=150 align=center>' . $row['Thumbnail Image'] .
    '<br>' . $row['Product Name'] .
    '<br>' . $row['Product Price'] . '</td>';

    ('Thumbnail Image' is the html of the image and with the above code it just displays the url of the image rather than the picture)

    Any help would be aprreciated

    Here a look of my whole code just so u can see how the above snippet fits in the mix:

    <?php
    //set the number of columns
    $columns = 3;
    mysql_connect('localhost','runsigne_main','guitar');
    mysql_select_db('runsigne_wtelectronics');
    $query = "SELECT * FROM `electronics_computer` ORDER BY `Product Price` ASC LIMIT 0, 30";
    $result = mysql_query($query);
    $picture=mysql_result($result,$i,"Thumbnail Image");
    //we add this line because we need to know the number of rows
    $num_rows = mysql_num_rows($result);
    echo "<TABLE BORDER=\"0\" width=\"450\">\n";

    //changed this to a for loop so we can use the number of rows
    for($i = 0; $i < $num_rows; $i++) {
    $row = mysql_fetch_array($result);
    if($i % $columns == 0) {
    //if there is no remainder, we want to start a new row
    echo "<TR>\n";
    }
    echo '<td width=150 align=center>' . $row['Thumbnail Image'] .
    '<br>' . $row['Product Name'] .
    '<br>' . $row['Product Price'] . '</td>';


    if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) {
    //if there is a remainder of 1, end the row
    //or if there is nothing left in our result set, end the row
    echo "</TR>\n";
    }
    }
    echo "</TABLE>\n";
    ?>

  2. #2
    Affiliate Manager
    Join Date
    January 18th, 2005
    Posts
    1,056
    Give it a try without all the periods in there...

    change:

    PHP Code:
    echo '<td width=150 align=center>' $row['Thumbnail Image'] . 
    '<br>' $row['Product Name'] . 
    '<br>' $row['Product Price'] . '</td>'
    to:

    PHP Code:
    echo "<td width=150 align=center><img src=$row[Thumbnail Image]><br>
    $row[Product Name]<br>
    $row[Product Price]</td>"

  3. #3
    Newbie
    Join Date
    April 24th, 2005
    Posts
    14
    ya i thought that would work i tried it earlier but got this error:

    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /home/runsigne/public_html/wtelectronics/horizontal.php on line 28

    Thanx for the quick response though

  4. #4
    Affiliate Manager
    Join Date
    January 18th, 2005
    Posts
    1,056
    You might need to make your db fields one word instead of two...

    E.G.

    PHP Code:
    echo "<td width=150 align=center><img src=$row[Thumbnail_Image]><br> 
    $row[Product_Name]<br> 
    $row[Product_Price]</td>"

  5. #5
    Newbie
    Join Date
    April 24th, 2005
    Posts
    14
    hmm that doesn't work either

  6. #6
    Resident Genius and Staunch Capitalist Leader's Avatar
    Join Date
    January 18th, 2005
    Location
    Florida
    Posts
    12,817
    I think you're missing the curly brackets around your $row variables.
    Try this:

    PHP Code:
    echo "<td width=150 align=center><img src={$row['Thumbnail Image']}><br> 
    {$row['Product Name']}<br> 
    {$row['Product Price']}</td>"
    That's how my code is--with the curly brackets around the $row variables, and single-quotes around the row names. Should work now...
    There is no knowledge that is not power. ~Hemingway

  7. #7
    Newbie
    Join Date
    April 24th, 2005
    Posts
    14
    That did the trick! Thanx i've been trying to work this out for days...sad i know
    thanks a ton!

  8. #8
    Making Affiliate Marketing FUN!
    Join Date
    January 18th, 2005
    Location
    Dallas, Texas
    Posts
    132
    It's great to see the AbestWeb community working together! This forum is truly a great source of knowledge!

  9. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. CJ's product image links
    By Rhia7 in forum Commission Junction - CJ
    Replies: 6
    Last Post: August 19th, 2006, 01:42 AM
  2. Product Image Animation
    By Allen Nance in forum Midnight Cafe'
    Replies: 0
    Last Post: October 25th, 2005, 04:38 PM
  3. Need a PHP Image/Wallpaper Script
    By onlineguide in forum Programming / Datafeeds / Tools
    Replies: 0
    Last Post: March 8th, 2005, 06:16 AM
  4. Image files and PHP
    By dak142 in forum Midnight Cafe'
    Replies: 0
    Last Post: October 8th, 2004, 02:40 PM

Posting Permissions

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