Image in table cell - possible?

Discussion in 'HTML & Website Design' started by username178452, Jun 27, 2008.

  1. #1
    I have a table listing products where each row corresponds to each product's data. One of the row's cell is the product image, which would be uploaded via its path (that is stored in the database). Is it possible to display an image on that cell (not as background).
     
    username178452, Jun 27, 2008 IP
  2. milesbparty

    milesbparty Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You mean something like this (very simplified of course):

    <table>
    <tr>
    <td>Product Description</td>
    <td><img "src=/path/file.jpg" /></td>
    </tr>
    </table>

    Does this answer your question?
     
    milesbparty, Jun 27, 2008 IP
  3. username178452

    username178452 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    First of all, thanks for replying.
    Yeah, theoretically that would work, i've tried it, but it show nothing but the same small image icon regardless of the image i try to input. Why is this? Please help me on this everyone, it's really important for me that you do.
     
    username178452, Jun 27, 2008 IP
  4. dylanj

    dylanj Peon

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Maybe you're getting the file paths wrong? I know, you're probably going to think that this is silly, but honestly, web designers are people, and people make mistakes. I do this sort of thing all the time, and then wake up the next day wondering how I got it wrong.

    Also, another silly thing: .jpeg is different to .jpg (Just in case)

    Otherwise, I don't know what the problem might be...
     
    dylanj, Jun 28, 2008 IP
  5. PokerBonus

    PokerBonus Member

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #5
    I would do this slightly differently - which may be your problem

    Notice I've put the quote mark in a different place.

    Use the full path of your image file (just to be sure) and make sure you've uploaded the image to the correct folder on your server.
     
    PokerBonus, Jun 28, 2008 IP
  6. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #6
    Try something like this:

    
    STYLE="background-image: 
         url('your_image.gif');
    
    Code (markup):
    Q...
     
    QiSoftware, Jun 28, 2008 IP
  7. username178452

    username178452 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for the replies people. Yeah, I've tried to put the full image path (which came in handy because I was trying to acess the images from an all different location as well), but the image does not display. It is there, I've checked it, but all that appears is something like an image error box. I even tried to put it as background, and it didn't work. Here's my code:


    [CODE]$query=mysql_query("SELECT * FROM produtos",$connection);
    $registos=mysql_num_rows($query);
    
    for($i=0;$i<$registos;$i++){
    $dados = mysql_fetch_assoc($query);
    $query_imagem=mysql_query("SELECT * FROM imagens WHERE produto=".$dados['id_produto']."",$connection);
    $imagem = mysql_fetch_assoc($query_imagem);
    if($dados['reservado']!=1){
    echo "<tr align=center> <td>".$dados['nome']."</td>";
    echo "<td>".$dados['marca']."</td>";
    echo "<td>".$dados['preco']." €</td>";
    echo "<td>".$dados['quantidade_stock']."</td>";
    echo "<td><input type='text' size='1' name='text_".$dados['id_produto']."'></td>";
    
    
    echo "<td background ='".$imagem['path']."'></td>";
    
    
    echo "<td align=right><input type='submit' name='button_".$dados['id_produto']."' value='Reservar'>
    <input type='hidden' name='pro[]'></a></td>";
    echo "</tr>";}[/CODE]
    PHP:
    I'm trying to associate the image with the respective product's id. What is wrong here? Please help.
     
    username178452, Jun 30, 2008 IP
  8. dylanj

    dylanj Peon

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #8
    I didn't notice that :)

    Another thing to do, would be to check file permissions on the picture file, especially if you're using Windows.
     
    dylanj, Jun 30, 2008 IP