SWITCH with a $_GET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sigzero@gmail.com

    SWITCH with a $_GET

    I have a url that ends with ?pid=sqlall. I am using the following to
    try and get at the "sqlall". I have read many sites to no avail.

    switch ($_GET['pid']) {
    case 'sqlall':
    $page->assign('pageti tle', 'All Users');
    $page->assign('tableh eader', 'All Users');
    $page->assign('sqlfil e', 'sql_all.php');
    break;
    case 'sqlprof':
    $page->assign('pageti tle', 'All Users');
    $page->assign('tableh eader', '» All User Profiles');
    $page->assign('sqlfil e', 'sql_prof.php') ;
    break;
    }

    if the url is http://localhost/main.php?pid=sqlall or ?pid=sqlprof then
    I want to case to assign. This is in conjuction with Smarty.
    Any suggestion would be helpful.

    Robert

  • Alvaro G. Vicario

    #2
    Re: SWITCH with a $_GET

    *** sigzero@gmail.c om escribió/wrote (7 Dec 2004 12:03:21 -0800):[color=blue]
    > I have a url that ends with ?pid=sqlall. I am using the following to
    > try and get at the "sqlall". I have read many sites to no avail.
    >
    > switch ($_GET['pid']) {
    > case 'sqlall':[/color]

    So, what's your problem? Have you done any sort of debugging, such us
    printing the variables? Is that the URL of current page or some other you
    have in a string?



    --
    -+ Álvaro G. Vicario - Burgos, Spain
    +- http://www.demogracia.com (la web de humor barnizada para la intemperie)
    ++ Las dudas informáticas recibidas por correo irán directas a la papelera
    -+ I'm not a free help desk, please don't e-mail me your questions
    --

    Comment

    • sigzero@gmail.com

      #3
      Re: SWITCH with a $_GET


      Alvaro G. Vicario wrote:[color=blue]
      > *** sigzero@gmail.c om escribió/wrote (7 Dec 2004 12:03:21 -0800):[color=green]
      > > I have a url that ends with ?pid=sqlall. I am using the following[/color][/color]
      to[color=blue][color=green]
      > > try and get at the "sqlall". I have read many sites to no avail.
      > >
      > > switch ($_GET['pid']) {
      > > case 'sqlall':[/color]
      >
      > So, what's your problem? Have you done any sort of debugging, such us
      > printing the variables? Is that the URL of current page or some other[/color]
      you[color=blue]
      > have in a string?
      >
      >
      >[/color]
      I have a "print_r" printing the $_GET. It IS displaying the right
      string but my assign statements are not assigning anything. I am
      calling the link from a JS using the following format:
      "attu.php?pid=s qlall"

      I am getting the "sqlall" it does not seem to be processing my assign->
      parameters in the switch statement itself.

      Robert

      Comment

      • sigzero@gmail.com

        #4
        Re: SWITCH with a $_GET

        It seems to be the Smarty cache causing the problem. Because I am using
        one page name "attu.php" the cache doesn't really see the change when I
        do different assigns to it. I turned the Smarty cache off and bingo the
        switch statement works.

        Robert

        Comment

        • Gary L. Burnore

          #5
          Re: SWITCH with a $_GET

          On 8 Dec 2004 10:30:27 -0800, sigzero@gmail.c om wrote:
          [color=blue]
          >It seems to be the Smarty cache causing the problem. Because I am using
          >one page name "attu.php" the cache doesn't really see the change when I
          >do different assigns to it. I turned the Smarty cache off and bingo the
          >switch statement works.
          >
          >[/color]
          It'd still be a bit better to do this:

          $pid = $_GET['pid'];

          switch ($pid) {
          case 'sqlall':

          ....



          --
          gburnore@databa six dot com
          ---------------------------------------------------------------------------
          How you look depends on where you go.
          ---------------------------------------------------------------------------
          Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
          | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
          DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
          | ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
          Black Helicopter Repair Svcs Division | Official Proof of Purchase
          =============== =============== =============== =============== ===============
          Want one? GET one! http://signup.databasix.com
          =============== =============== =============== =============== ===============

          Comment

          • Daniel Tryba

            #6
            Re: SWITCH with a $_GET

            Gary L. Burnore <gburnore@datab asix.com> wrote:[color=blue]
            > It'd still be a bit better to do this:
            >
            > $pid = $_GET['pid'];
            >
            > switch ($pid) {
            > case 'sqlall':
            >
            > ...
            >[/color]

            Huh! Why?

            Comment

            • Daniel Tryba

              #7
              Re: SWITCH with a $_GET

              sigzero@gmail.c om wrote:[color=blue]
              > It seems to be the Smarty cache causing the problem. Because I am using
              > one page name "attu.php" the cache doesn't really see the change when I
              > do different assigns to it. I turned the Smarty cache off and bingo the
              > switch statement works.[/color]

              See the msarty manual how to have multiple caches for 1 page:


              Comment

              • Gary L. Burnore

                #8
                Re: SWITCH with a $_GET

                On 09 Dec 2004 19:12:20 GMT, Daniel Tryba <spam@tryba.inv alid> wrote:
                [color=blue]
                >Gary L. Burnore <gburnore@datab asix.com> wrote:[color=green]
                >> It'd still be a bit better to do this:
                >>
                >> $pid = $_GET['pid'];
                >>
                >> switch ($pid) {
                >> case 'sqlall':
                >>
                >> ...
                >>[/color]
                >
                >Huh! Why?[/color]

                Moving the $_GET stuff in to their own variables is a good habit to
                get into for more than one reason. One is less typing on re-use.
                It's easier to type $pid more than once rather than typing
                $_GET['pid'] more than once for example.



                --
                gburnore@databa six dot com
                ---------------------------------------------------------------------------
                How you look depends on where you go.
                ---------------------------------------------------------------------------
                Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
                | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
                DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
                | ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
                Black Helicopter Repair Svcs Division | Official Proof of Purchase
                =============== =============== =============== =============== ===============
                Want one? GET one! http://signup.databasix.com
                =============== =============== =============== =============== ===============

                Comment

                • Daniel Tryba

                  #9
                  Re: SWITCH with a $_GET

                  Gary L. Burnore <gburnore@datab asix.com> wrote:[color=blue][color=green][color=darkred]
                  >>> It'd still be a bit better to do this:
                  >>>
                  >>> $pid = $_GET['pid'];
                  >>>
                  >>> switch ($pid) {
                  >>> case 'sqlall':
                  >>>
                  >>> ...
                  >>>[/color]
                  >>
                  >>Huh! Why?[/color]
                  >
                  > Moving the $_GET stuff in to their own variables is a good habit to
                  > get into for more than one reason. One is less typing on re-use.
                  > It's easier to type $pid more than once rather than typing
                  > $_GET['pid'] more than once for example.[/color]

                  That must be the worst reason I ever heard! Offcourse varriables should
                  be to the point and descriptive. But that doens't mean shorter is
                  always better.

                  But $_GET['pid'] says something extra, like that it came from an
                  untrustworthy source. Making a raw copy hides that fact, so when $pid is
                  later used in output there is a chance that correctly escaping will be
                  forgotten.

                  Comment

                  Working...