Re: Re: Applying the elseif and switch statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To expand on what skotfred wrote, all of your elseif conditions need  
to have ==
THIS:
elseif ($mean = "ordinarily")
SHOULD BE THIS:
elseif ($mean == "ordinarily")

As one example.

On a side note, before you ever enter that logic, $mean is ALWAYS set  
to 'simple'. I don't know if you meant to have it in an array or  
anything like that.
--
Joe

On Apr 12, 2010, at 12:41 PM, skotfred wrote:

> Gab, for your comparisons you need to be sure to have two equals  
> signs (==, not =), otherwise it becomes an assignment and always  
> returns 'true'.
> --- In php-objects@xxxxxxxxxxxxxxx, Gab Teo <doneatlast1000@...>  
> wrote:
> >
> > Hello,
> >
> > I created a page that will enable users to go to the page of the  
> item they chose as mean with their passcode (username and  
> password),  and I used the elseif statement and the switch statement.
> >
> > 1. For  the elseif statemnet, the output seems to be the same as  
> it take me to:  header("Location:ordinarily.php");
> > irrespective of the mean chosen
> > 2.  And again for  the switch statemnet, the output seems to be  
> the same as well, it take me to:   header("Location:simple.php");
> > irrespective of the mean chosen
> >
> >
> > can anyone figure out what I need to put right
> > Thanks,
> > Gab
> >
> > <?php
> > if (!empty($_POST[Submit]))
> > {
> > include ("databaseconnect.php");
> > $username=$_SESSION[12345];
> >
> > $page=mysql_query("SELECT * from mean where mean='$mean'");
> >
> > if(mysql_num_rows($page)==0)
> > echo"<ul><font color=red><b>Not available</b></font></ul>";
> >
> >
> > $mean= "ordinarily";
> > $mean = "major";
> > $mean = "simple";
> >
> >    elseif ($mean = "ordinarily")
> >    {
> >    header("Location:ordinarily.php");
> >   }
> >    elseif ($mean = "major")
> >    {
> >    header("Location:major.php");
> >   }
> >   elseif ($course = "simple")
> >    {
> >    header("Location:simple.php");
> >   }
> > else
> > echo"Rgister for mean";
> >    }
> > }
> >
> >
> > ?>
> >
> > The switch statement
> >
> >
> > <?php
> > if (!empty($_POST[Submit]))
> > {
> > include ("databaseconnect.php");
> > $username=$_SESSION[12345];
> >
> > $page=mysql_query("SELECT * from mean where mean='$mean'");
> >
> >
> > if(mysql_num_rows($page)==0)
> >
> > echo"<ul><font color=red><b>Not available</b></font></ul>";
> >
> > $mean= "ordinarily";
> > $mean = "major";
> > $mean = "simple";
> >
> > switch ("$mean")
> >  {
> >    case "ordinarily" :
> >    header("Location:ordinarily.php");
> >    break;
> >    case "major" :
> >    header("Location:major.php");
> >    break;
> >    case "simple" :
> >    header("Location:simple.php");
> >    break;
> >    default :
> >    echo"Rgister for mean";
> >    break;
> >    }
> > }
> >
> > ?>
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
> 



[Non-text portions of this message have been removed]



------------------------------------

Are you looking for a PHP job?
Join the PHP Professionals directory Now!
http://www.phpclasses.org/jobs/
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-objects/join
    (Yahoo! ID required)

<*> To change settings via email:
    php-objects-digest@xxxxxxxxxxxxxxx 
    php-objects-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux