1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

In need of more PHP help..again

Discussion in 'PHP & Perl' started by glew, May 20, 2009.

  1. glew

    glew Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    141
    Likes Received:
    93
    I figured out my last problem on my own, but now i've ran into another one.

    i'm trying to put this code
    Code:
    <div style="float:left; margin-right: 5px"><img src="<?php $key="fav"; echo get_post_meta($post->ID, $key, true); ?>" /></div>
    next to the <li> tag here
    Code:
    print "<li>***code here***<a href='". get_permalink($post->id) ."'>".$post->post_title."</a></li>\n";
    it's the code for custom field image and i want each image to show up next to each title.

    if someone could help with a solution i would be really greatful :(
     
  2. detox1978

    detox1978 Junior Member

    Joined:
    Jan 16, 2009
    Messages:
    110
    Likes Received:
    33
    Can't really get into a CSS lesson on how it should be done, but a quick fix would be to remove the DIV tag and add a few spaces, which are  



    Code:
    print "<li><img src="<?php $key="fav"; echo get_post_meta($post->ID, $key, true); ?>" />   <a href='". get_permalink($post->id) ."'>".$post->post_title."</a></li>\n";
     
  3. glew

    glew Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    141
    Likes Received:
    93
    thanks for the reply detox, but didn't work. Your code is not escaped properly. The image can't show up that way.
     
  4. detox1978

    detox1978 Junior Member

    Joined:
    Jan 16, 2009
    Messages:
    110
    Likes Received:
    33
    So escape it...????

    Code:
    
    <?php 
    
    $key="fav"; 
    $varImage = get_post_meta($post->ID, $key, true); 
    
    print "<li><img src=\"". $varImage ."\" />   <a href='". get_permalink($post->id) ."'>".$post->post_title."</a></li>\n";
    
    ?>
    
    
     
    • Thanks Thanks x 1
  5. glew

    glew Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    141
    Likes Received:
    93
    Detox you are a god :champion: and I am an idiot :rocketwho

    I was echoing $key instead of $varimage!

    Thanks brotha you are a lifesaver :whee: