Jump to content

[SOLVED] top three results


MoFish

Recommended Posts

Hello. I'm currently making a league and wanted icons beside the top three positions in the league table: gold, silver and bronze.

 

The code im using appears to be working to some extent, but .. the 4th row is blank all the time.

 

If i add a 4th value to the array, it simply shifts to the 5th row being blank.

 

I cant figure out whats going on here at all.

 

can anyone see the problem? i've been trying to find it out for days now.

 

leagueimagewr9.jpg

 

<?php
error_reporting(E_ALL);
$colors=array('#DAEBFF', '#DAEBFF', '#DAEBFF');
$images=array('gold1.gif', 'silver1.gif', 'bronze1.gif');
do{
if(isset($colors)){
  $color=array_shift($colors);
  if(is_null($color)){
   unset($colors);
  }
}else{
  $color='#C4DFFF';
}
if(isset($images)){
  $image=array_shift($images);
  if(is_null($image)){
   unset($images);
  }
}else{
  $image='none.gif';
}

//all my display table is here
//echo "<img src='images/" . $image ."'>"; etc

}while($row_SelectAllLeague=mysql_fetch_assoc($SelectAllLeague));
?>

Link to comment
https://forums.phpfreaks.com/topic/49969-solved-top-three-results/
Share on other sites

the top three are suppost to be gold.gif silver.gif and bronze.gif, the rest are suppost to be none.gif.

 

source from page = "  <td align="center"><img src='images/'></td> " - nothing :(

 

oh, so if the first element is removed from the array... how does the gold icon still appear?

 

confusing

try this

 

<?php
error_reporting(E_ALL);
$colors=array('#DAEBFF', '#DAEBFF', '#DAEBFF');
$images=array('gold1.gif', 'silver1.gif', 'bronze1.gif');
do{
if(isset($colors)){
  $color=array_shift($colors);
  if(is_null($color)){
   unset($colors);
  }
}else{
  $color='#C4DFFF';
}
if(isset($images)){
  $image=array_shift($images);
  if(is_null($image)){
   $image='none.gif';
  }


//all my display table is here
//echo "<img src='images/" . $image ."'>"; etc

}while($row_SelectAllLeague=mysql_fetch_assoc($SelectAllLeague));
?>

I am probably missing a closing bracket }

 

 

this:

if(isset($images)){
  $image=array_shift($images);
  if(is_null($image)){
   $image='none.gif';
  }

 

should be this

if(isset($images)){
  $image=array_shift($images);
  if(is_null($image)){
   $image='none.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.