PHP Array Help

I created a table to recognize specific players for donations. The table displays their game name and the title that they earned. I want to put in these star images to the left of their name in a separate column, but I can’t figure out how to do this. There are five different titles and a star image for each title. So if they are a Titanium Member, I would want the Titanium Star image to be to the left of their name.

Can anybody tell me how do to this? I’m not very well versed in PHP, but I’m trying to learn. Thanks!

[code][php]

<?php

$d_player = array(“Asseletion”, “Bill_theButcher”, “ShRaPnEl”, “Dadfish”, “Tyexan”, “BeBop”, “BMH”, “DSR”, “Gloch”, “Smokin_Good”, “MrGreen”, “MVP”, “Scorpion_Sting”, “Patricking”, “Thumbs”);
$d_title = array(“Titanium Member”, “Titanium Member”, “Titanium Member”, “Platinum Member”, “Platinum Member”, “Gold Member”, “Gold Member”, “Gold Member”, “Gold Member”, “Gold Member”, “Silver Member”, “Silver Member”, “Silver Member”, “Bronze Member”, “Bronze Member”);

for ($i=1;$i<=15;$i++){
if ($loop==0){ $background=“141414”; $loop=10; } else { $background=“000000”; $loop=0;}
?>

<?php } echo "
Recognized Player Earned Title
<?php echo $i; ?> <?php echo $d_player[$i-1]; ?> <?php echo $d_title[$i-1]; ?>
These are players who deserve recognition for donating to the campaign that helped keep BA going and get on the path to better days. Special thanks to these players!
"; [/php][/code]

Why are you hardcoding the names? it would be easier to setup a database to contain that kind of information. But to look at the issue, i’d do a multidemensional array

$d_title = array(“Titanium Member” => “titanium_star.jpg”, “Titanium Member” => “titanium_star.jpg”, “Titanium Member” => “titanium_star.jpg”, “Platinum Member” => “platinum_star.jpg”, “Platinum Member” => “platinum_star.jpg”, “Gold Member” => “gold_star.jpg”, “Gold Member” => “gold_star.jpg”, “Gold Member” => “gold_star.jpg”, “Gold Member” => “gold_star.jpg”, “Gold Member” => “gold_star.jpg”, “Silver Member” => “silver_star.jpg”, “Silver Member” => “silver_star.jpg”, “Silver Member” => “silver_star.jpg”, “Bronze Member” => “bronze_star.jpg”, “Bronze Member” => “bronze_star.jpg”);

You could also just create another arrray, but it would be a tad difficult to get them sorted and merged properly.

You’re also not closing out the row before you close the table.

I tried what you wrote and it didn’t seem to do anything. So I continued to look around and I tried the following, but that doesn’t work either. Is there something specific that I’m doing wrong?

[code][php]


<?php } echo "
	<p><div class='border_01'><table width='100%' border='0' cellpadding='3' cellspacing='0' align='center'>
      <tr class='tableHdr'>
          <td width='20'></td>
          <td width='200' align='left'>Recognized Player</td>
          <td colspan='2' align='left'>Earned Title</td>
        </tr>
<?php $titanium = "../images/donation/titanium_star.jpg"; $platinum = "../images/donation/platinum_star.jpg"; $gold = "../images/donation/gold_star.jpg"; $silver = "../images/donation/silver_star.jpg"; $bronze = "../images/donation/bronze_star.jpg"; $d_star = array("<img src=".$titanium."", "<img src=".$titanium."", "<img src=".$titanium."", "<img src=".$platinum."", "<img src=".$platinum."", "<img src=".$gold."", "<img src=".$gold."", "<img src=".$gold."", "<img src=".$gold."", "<img src=".$gold."", "<img src=".$silver."", "<img src=".$silver."", "<img src=".$silver."", "<img src=".$bronze."", "
   <tr onmouseover="this.bgColor='#333333';" onmouseout="this.bgColor='#<?php echo $background; ?>';" bgcolor="#<?php echo $background; ?>">
<?php echo $i; ?></td <?php echo $d_star [$i-1]; ?> <?php echo $d_player[$i-1]; ?> <?php echo $d_title[$i-1]; ?>
These are players who deserve recognition for donating to the campaign that helped keep BA going and get on the path to better days. Special thanks to these players!
";[/php][/code]

There’s no association between the people, levels and stars. Goto php.net and look at the array functions

I don’t really want to associate them. I just want the images to appear in the order I want in that column. This isn’t a table that will change, the information will remain static.

ok, have a look at this site http://www.mydigitallife.info/how-to-access-php-array-and-multidimensional-nested-arrays-code-syntax/, go down to the last example - that’s exactly what you need to do what you’re trying to accomplish.

Sponsor our Newsletter | Privacy Policy | Terms of Service