Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    image from list function array

    i have this piece of code that works fine
    PHP Code:
                        $sql2"SELECT country, GROUP_CONCAT(name ORDER BY country SEPARATOR '<br>') as name       
                                FROM tanks_owned
                                where player = '$player'        
                                GROUP BY country"
    ;

                        
    $result2=mysql_query($sql2);

                        while (list(
    $country$name) = mysql_fetch_row($result2)) {   
                      
                                  echo 
    "<div style='width:90px; padding:5px; float:left;'>        
                                  <h4><img src='./icon/country/$country.png'></h4>$name
                                  
                                          </div>"
    ;
                        } 
    i want to change it so that an image is displaye rather than text
    example
    PHP Code:
                        $sql2"SELECT country, GROUP_CONCAT(name ORDER BY country SEPARATOR '<br>') as name       
                                FROM tanks_owned
                                where player = '$player'        
                                GROUP BY country"
    ;

                        
    $result2=mysql_query($sql2);

                        while (list(
    $country$name) = mysql_fetch_row($result2)) {   
                      
                                  echo 
    "<div style='width:90px; padding:5px; float:left;'>        
                                  <h4><img src='./icon/country/$country.png'></h4><img src="
    ./icon/tank/$country-$name.png"/>
                                  
                                          </div>"
    ;
                        } 
    the image src in the above dosent work as the $name value is an array. is it possable to make it as i want?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,213
    Thanks
    23
    Thanked 605 Times in 604 Posts
    In your second code area you are using double quotes on the second image src, they have to be excaped or made single:
    Code:
    echo "<div style='width:90px; padding:5px; float:left;'>        
    <h4><img src='./icon/country/$country.png'></h4><img src='./icon/tank/$country-$name.png'/>
    </div>";


  •  

    Posting Permissions

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