mullerrwd Posted March 18, 2009 Share Posted March 18, 2009 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 Link to comment https://forums.phpfreaks.com/topic/149996-changing-array-values-problem-pls-help-newbie/ Share on other sites More sharing options...
Mark Baker Posted March 18, 2009 Share Posted March 18, 2009 <td><p><img src=\"themes/default/images/gif/{$rr['country']['Switzerland']}\" /></p></td> Link to comment https://forums.phpfreaks.com/topic/149996-changing-array-values-problem-pls-help-newbie/#findComment-787774 Share on other sites More sharing options...
mullerrwd Posted March 18, 2009 Author Share Posted March 18, 2009 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 Link to comment https://forums.phpfreaks.com/topic/149996-changing-array-values-problem-pls-help-newbie/#findComment-787780 Share on other sites More sharing options...
Mark Baker Posted March 18, 2009 Share Posted March 18, 2009 You use a table of countries in your database, and when do a select on your user you do a db join to the countries table Link to comment https://forums.phpfreaks.com/topic/149996-changing-array-values-problem-pls-help-newbie/#findComment-787784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.