elseif statements

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rxroids
Forum Newbie
Posts: 5
Joined: Fri Apr 06, 2007 10:29 pm

elseif statements

Post by rxroids »

I'm using this code:

Code: Select all

<?php //Middle Initial
				if(!empty($_POST['middle_ini']))
					{
					echo ' '.($_POST['middle_ini']).'.';
					}
					elseif(empty($_POST['first_name'])&&(empty($_POST['middle_ini']))
					{
					echo 'Monkey';
					}
                                        else
                                        {
                                        echo ' ';
                                        }
			?>
If middle_ini is not empty show: ' '.($_POST['middle_ini']).'.' But if first_name AND middle_ini ARE empty show Monkey. Something is wrong with my code cuz i keep gettin an error message.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

What do I win if I go through your code and correctly guess what the error message is?
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

Always mention which error you are getting. Rewrite your elseif statment line i.e. line 6.
nitrino
Forum Newbie
Posts: 10
Joined: Tue Jan 02, 2007 10:22 am
Location: Riga, Latvia

Post by nitrino »

maybe use switch...case instead.
Post Reply