Jump to content

Changing array values problem, pls help newbie


mullerrwd

Recommended Posts

Hi there,

first, I recently began programming php. I am currently busy with a member script (for learning).

But I ran into a problem. In  themes/default/memberlist.php

A list is obtained of all members registered. This wasn't really dificult to do. But here's the catch. I want to display a members country falg infront of the username like so:

 

[flagimage] | [username] | [lastaction]

 

I got this so far:

<?php
///mysql query is done no need to post that
$contents.= "<tr>
<td><p><img src=\"themes/default/images/gif/{$rr['country']}\" /></p></td>
<td><p>{$rr['username']}</p></td>
<td><p>".date("d/m/Y",$rr['lastaction'])."</p></td>
</tr>";
?>

 

Now the variable $rr['country'] obviously contains the countries (in full, ex Switzerland),but how do I change the array from Switzerland to ch.gif. I tried to do it like this.

In /lib/configuration.php I added this (/lib/configuration.php is included in header)

<?php
$rr['country'] = array(
                            'Switzerland' => ch.gif,  //just one example i add all countries later
                            );

 

But this doesnt make the change 'Switzerland' => ch.gif

when i test it with a virtual memeber who lives in Switzerland I get a no-image displayed with this url: www.website.com/themes/default/images/gif/Switzerland and not www.website.com/themes/default/images/gif/ch.gif

 

I know that you are all thinking 'why not renaming all images'. Well i want to learn how to program well in php.;)

Thanks in advance,

Robert

But then i will have to be doing this for evryone.

say if there were 1000 members, how should i do that. $rr['country'] wil then contain 1000 countries ordered depending on how I extract them from the db and list them. But how to change all values in the array to the iso.gif

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.