Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-16-2013, 12:29 AM   PM User | #1
hyster
New to the CF scene

 
Join Date: Jan 2013
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
hyster is an unknown quantity at this point
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?
hyster is offline   Reply With Quote
Old 02-16-2013, 05:34 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,365
Thanks: 18
Thanked 348 Times in 347 Posts
sunfighter is on a distinguished road
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>";
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Advertisement
Log in to turn off these ads.