PDA

View Full Version : If ...Else...help please!!


naeemakhtar
24 Jun 2006, 12:05
Hi there all.

Im new to PHP but having some troube in getting some simple bit of code to work.And I am trying...

I know that the syntax for a PhP if..Else test is basically:

<
if(condition)
dothis....
else
dothat....
>

But inside VBulletin when I go to edit my navbar template I see this:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


Thats basically shows a graphic if there is an unread PM.But if there isnt I want it to show a different graphic. So I figured the best thing to do is a if..else statement. No matter what I do it seems to fall over or the else isnt recognised. Can someone tell me why?



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


As far as i can tell the angle brackets just help to keep selcted bits of code together in a block in php and should be translated into HTML at execution time....still dont know why its not working.Can anyone explain why to me please?:(

Many thanks,
Naeem

anyone???

Code Monkey
24 Jun 2006, 15:15
<else />

Kirk Y
24 Jun 2006, 16:56
You might also want to switch your images -- you've got the No New PMs image being displayed when there are Unread Messages and the New PMs Image being displayed when there aren't any.

naeemakhtar
24 Jun 2006, 23:05
You might also want to switch your images -- you've got the No New PMs image being displayed when there are Unread Messages and the New PMs Image being displayed when there aren't any.

LOL Thanks Guy's. Yep I noticed I did that too and I was gonna go back to edit it but I realised by the time I noticed on the editing what I had done, it would be spotted!!!:D So well spotted and thanks....

Dont worry it wasnt like that in the actual code as I didnt copy and paste all of it 1st time around. Below is the actual code I put in with <IF><Else/> and its still not working.

Basically if there is a message then show newpm.gif otherwise show nonewpm.gif...at the moment it shows neither or both! For the life of me I really cant see why it shouldnt work....it still 'reads' good to me.:surprised:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


I hope you can spot something in it that I cant...and thanks again for your time and help.

Code Monkey
24 Jun 2006, 23:13
<else /> don't forget the space before the / and it's better if you post your code here in code tags.

naeemakhtar
24 Jun 2006, 23:34
<else /> don't forget the space before the / and it's better if you post your code here in code tags.

Yaaaaaaaaaaaaaay!!! Thanks a lot for pointing that out for me!!! It works great now!!!

I always thought that the space before the > didnt matter and that the space was just insignificant! Now i know...many thanks again for your help :)