• Resolved cerberus478

    (@cerberus478)


    Hi

    I’m trying to get an image to show on a page, but I get a little box with a torn image.

    This is the code I used

    <?php global $wpdb;
          $bras = $wpdb->get_results("SELECT * FROM bras;");
    ?>			
    
    <table>
       <?php foreach($bras as $bra): ?>
    
       <td><?php echo $bra->title ?><br />
       <img src="<?php echo $bra->filename; ?>" /><br />
       <?php echo $bra->content ?><br />
       <?php echo $bra->price ?><br />
    
    <?php endforeach; ?>
    </td>
    </table>
Viewing 2 replies - 1 through 2 (of 2 total)
  • what is in your ‘bras’ database table?

    what is the content of the ->filename

    imho, you would need to have an absolute image url in there to get it to show properly on all pages (index, archives, single,..)

    Thread Starter cerberus478

    (@cerberus478)

    Hi

    Thanks for your reply, I found out what I need to do.

    This is what I did, in case anyone else wants to know

    <?php global $wpdb;
            $bras = $wpdb->get_results("SELECT * FROM bras;");
    ?>			
    
    	<table>
    	<?php foreach($bras as $bra): ?>
    
    	<td><?php echo $bra->title ?><br />
    	<img src="<?php echo      bloginfo('template_directory').'/img/'.$bra->filename; ?>" /><br />
    
    <?php echo $bra->content ?><br />
    <?php echo $bra->price ?><br />
    
    <?php endforeach; ?>
    </td>
    </table>

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘image problem’ is closed to new replies.