CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   image from list function array (http://www.codingforums.com/showthread.php?t=287723)

hyster 02-16-2013 12:29 AM

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?

sunfighter 02-16-2013 05:34 PM

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>";



All times are GMT +1. The time now is 01:23 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.