Jump to content
MakeWebGames

Recommended Posts

Posted

Ok so I want it to display 5 images:

jail.gif - When nobody is in jail (green jail pic)

jail2.gif - When 1 or more are in jail (Red jail pic)

hospital.gif - When nobody in hosp (green hosp pic)

hospital2.gif - When 1 or more in hosp (yellow hosp pic)

hospital3.gif - When 5 or more in hosp (red hosp pic)

 

if($jc > 0) { print "[url='jail.php'][img=*****/jail2.gif][/url]"; }
else { print "[url='jail.php'][img=*****/jail.gif][/url]"; }
if($hc > 10) { print "[url='hospital.php'][img=*****/hospital3.gif][/url]"; }
else if($hc == 0) { print "[url='hospital.php'][img=*****/hospital2.gif][/url]"; }
else { print "[url='hospital.php'][img=*****/hospital.gif][/url]"; }

 

When I use that, it only shows the green pic, even when 16 people are in hospital. Any help will be appreciated

Posted

Re: Jail and Hospital

 

if($jc == 0)
{
echo 'green jail pic';
}
else
{
echo 'red jail pic';
}

//
//Now for hospital
//

if($hc == 0)
{
echo 'green hos pic';
}
else if($hc > 0 && $hc < 5)
{
echo 'yellow hosp pic';
}
else
{
echo 'red hosp pic';
}

Posted

Re: Jail and Hospital

Tried both, got unexpected T_String. Here's Lithium's one, uncensored >.< Just spaced out so it's easier for me (I'm too tired atm)

 

echo $jc = ($jc) ? 

'[url='jail.php'][img=ikony/jail.gif][/url]' 

: '[url='jail.php'][img=ikony/jail2.gif][/url]';

echo $hc = (!$hc) ? 

'[url='hospital.php'][img=ikony/hospital.gif][/url]'

: ($hc > '0' && $hc < '5') ? 

'[url='hospital.php'][img=ikony/hospital2.gif][/url]' : 

'[url='hospital.php'][img=ikony/hospital3.gif][/url]';

 

Please correct that if it's wrong.

Posted

Re: Jail and Hospital

 

echo $jc = ($jc) ?  '[url="jail.php"][img=ikony/jail.gif][/url]'  : '[url="jail.php"][img=ikony/jail2.gif][/url]';

 

and

 

echo $hc = (!$hc) ? '[url="hospital.php"][img=ikony/hospital.gif][/url]' : ($hc > '0' && $hc < '5') ? '[url="hospital.php"][img=ikony/hospital2.gif][/url]' : '[url="hospital.php"][img=ikony/hospital3.gif][/url]';
Posted

Re: Jail and Hospital

@ gurpreet... see the difference between my last and yours? that was the reason you got the error ;)

oh... replace the code of your OP for this one

 

if($jc > 0) { print "[url='jail.php'][img=*****/jail2.gif][/url]"; }
else { print "[url='jail.php'][img=*****/jail.gif][/url]"; }
if($hc > 10) { print "[url='hospital.php'][img=*****/hospital3.gif][/url]"; }
else if($hc == 0) { print "[url='hospital.php'][img=*****/hospital2.gif][/url]"; }
else { print "[url='hospital.php'][img=*****/hospital.gif][/url]"; }

 

trash this bit away and place the one i posted last

Posted

Re: Jail and Hospital

 

echo $jc = ($jc) ?  '[url="jail.php"][img=ikony/jail.gif][/url]'  : '[url="jail.php"][img=ikony/jail2.gif][/url]';

 

and

 

echo $hc = (!$hc) ? '[url="hospital.php"][img=ikony/hospital.gif][/url]' : ($hc > '0' && $hc < '5') ? '[url="hospital.php"][img=ikony/hospital2.gif][/url]' : '[url="hospital.php"][img=ikony/hospital3.gif][/url]';

 

Yeh, I think something is up with my files, because this shows the yellow of each (No people in jail or hosp, so it should be green)

Posted

Re: Jail and Hospital

do a print_r($jc); and print_r($hc); just to see what each one returns when you call them. you can place those right near the displays so you can know what is what

Posted

Re: Jail and Hospital

 

do a print_r($jc); and print_r($hc); just to see what each one returns when you call them. you can place those right near the displays so you can know what is what

They both produce the yellow pic. 2 were in hospital, 0 in jail.

Posted

Re: Jail and Hospital

 

//Jail
echo ((!$jc)
   ? '[url="jail.php"][img=ikony/jail.gif][/url]'  
   : '[url="jail.php"][img=ikony/jail2.gif][/url]');
//Hospital
echo ((!$hc)
   ? '[url="hospital.php"][img=ikony/hospital.gif][/url]'
   : (($hc >= 5)
       ? '[url="hospital.php"][img=ikony/hospital3.gif][/url]'
       : '[url="hospital.php"][img=ikony/hospital2.gif][/url]'));

 

Try that..

Posted

Re: Jail and Hospital

 

//Jail
echo ((!$jc)
   ? '[url="jail.php"][img=ikony/jail.gif][/url]'  
   : '[url="jail.php"][img=ikony/jail2.gif][/url]');
//Hospital
echo ((!$hc)
   ? '[url="hospital.php"][img=ikony/hospital.gif][/url]'
   : (($hc >= 5)
       ? '[url="hospital.php"][img=ikony/hospital3.gif][/url]'
       : '[url="hospital.php"][img=ikony/hospital2.gif][/url]'));

 

Try that..

That doesn't seem to work...I may give up on this idea, it's not a priority. Thanks for your help everyone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...