Jump to content

[SOLVED] whats wrong here


serverman

Recommended Posts

here is the whole thing and yeah i is 1-5 never lands on 0... 0 means an error here is more of the script

$i = $r['cat_id'];
  switch ($i) 
  {
case 0:
   echo "nothing<br>";
   break;
case 1:
   echo '<img src="../img/php.gif" alt="" ><br>';
   break;
case 2:
   echo '<img src="../img/asp.gif" alt="" ><br>';
   break;
case 3:
   echo '<img src="../img/sql.gif" alt="" ><br>';
   break;
case 4:
   echo '<img src="../img/java.gif" alt="" ><br>';
   break;
case 5:
   echo '<img src="../img/html.gif" alt="" ><br>';
   break;	}

i dont know why but this fixed it

 {
case 0:
    echo "nothing<br>";
    break;
case 1:
  ?><img src="../img/php.gif" alt="" ><br><?php
    break;
case 2:
?><img src="../img/asp.gif" alt="" ><br><?php
    break;
case 3:
  ?><img src="../img/sql.gif" alt="" ><br><?Php
    break;
case 4:
  ?><img src="../img/java.gif" alt="" ><br><?php 
    break;
case 5:
   ?><img src="../img/html.gif" alt="" ><?php
    break;	}

Can't see anything wrong with it. And you're sure that the image path is right? I ask again: What is the output of the script (HTML source)? And the obvious question: Have you check that $i is not empty?? Your code is pretty repetitive. You can try:

 

<?php
$i = $r['cat_id'];
$cats = array('php', 'asp', 'sql', 'java', 'html');
if ($i > 0 && $i < 6) {
echo '<img src="../img/', $cats[$i - 1], '.gif" alt="" /><br />';
} elseif ($i == 0) {
echo 'nothing<br />';
}
?>

here it is http://67.235.135.133/tutorial/index.php working

im not shure why it works now but it does :P

it outputs the same thing without the change i made that fixed it but the pics didnt show up on firefox3

 

 

... now im going to try your fix it looks cleaner :P and like it will run faster

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.