Begininger to PHP, requesting a little help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric R.

    Begininger to PHP, requesting a little help

    I was looking through php.net's help guide and a few other documents
    that I cam across on the web but I am still having trouble finding the
    information I am looking for. So I came here...

    Here is my question:
    I was wondering if there was a way to load information into a page
    without using SQL or anything fancy. Say I had a page setup with the
    body of the page being pulled in with a 'require' command and a menu
    bar on the left. (This page would be my index.php). I was wondering if
    there was a way to make the links on the menubar pull different
    information into the page where the require command is. Perhaps making
    different links into variables and then calling those variables with
    the menu links.

    I really don't know how to explain this but I think it is rather
    simple. If anyone knows how to go about this and would like to take
    the time to respond to this it would be greatly appreciated. Thank
    you!

    Regards,

    Eric Rines

    Thanks in advance for any help with my issue at hand!
  • Sacs

    #2
    Re: Begininger to PHP, requesting a little help

    Eric R. wrote:[color=blue]
    > I was looking through php.net's help guide and a few other documents
    > that I cam across on the web but I am still having trouble finding the
    > information I am looking for. So I came here...
    >
    > Here is my question:
    > I was wondering if there was a way to load information into a page
    > without using SQL or anything fancy. Say I had a page setup with the
    > body of the page being pulled in with a 'require' command and a menu
    > bar on the left. (This page would be my index.php). I was wondering if
    > there was a way to make the links on the menubar pull different
    > information into the page where the require command is. Perhaps making
    > different links into variables and then calling those variables with
    > the menu links.
    >
    > I really don't know how to explain this but I think it is rather
    > simple. If anyone knows how to go about this and would like to take
    > the time to respond to this it would be greatly appreciated. Thank
    > you!
    >
    > Regards,
    >
    > Eric Rines
    >
    > Thanks in advance for any help with my issue at hand![/color]

    Perhaps something like:

    index.php:

    <html>
    <head></head>
    <body>

    <table border=1 width=80%>
    <tr>
    <td width=200>
    <ul>
    <li><a href="index.php ?t=main">Main</a></li>
    <li><a href="index.php ?t=news">News</a></li>
    </ul>
    </td>
    <td>

    <?php
    $t=$_GET['t'];
    switch($t) {
    case ("main") :
    require "main.php";
    break;
    case ("news") :
    require "news.php";
    break;
    default:
    require "home.php";
    break;
    }
    ?>

    </td>
    </tr>
    </table>
    </body>
    </html>

    Comment

    • Andy Jacobs

      #3
      Re: Begininger to PHP, requesting a little help

      On 18/11/04 11:15 pm, in article %1and.3607$9A.1 44872@news.xtra .co.nz,
      "Sacs" <alan_nospam_@w ay.co.nz> wrote:
      [color=blue]
      > Eric R. wrote:[color=green]
      >> I was looking through php.net's help guide and a few other documents
      >> that I cam across on the web but I am still having trouble finding the
      >> information I am looking for. So I came here...
      >>
      >> Here is my question:
      >> I was wondering if there was a way to load information into a page
      >> without using SQL or anything fancy. Say I had a page setup with the
      >> body of the page being pulled in with a 'require' command and a menu
      >> bar on the left. (This page would be my index.php). I was wondering if
      >> there was a way to make the links on the menubar pull different
      >> information into the page where the require command is. Perhaps making
      >> different links into variables and then calling those variables with
      >> the menu links.
      >>
      >> I really don't know how to explain this but I think it is rather
      >> simple. If anyone knows how to go about this and would like to take
      >> the time to respond to this it would be greatly appreciated. Thank
      >> you!
      >>
      >> Regards,
      >>
      >> Eric Rines
      >>
      >> Thanks in advance for any help with my issue at hand![/color]
      >
      > Perhaps something like:
      >
      > index.php:
      >
      > <html>
      > <head></head>
      > <body>
      >
      > <table border=1 width=80%>
      > <tr>
      > <td width=200>
      > <ul>
      > <li><a href="index.php ?t=main">Main</a></li>
      > <li><a href="index.php ?t=news">News</a></li>
      > </ul>
      > </td>
      > <td>
      >
      > <?php
      > $t=$_GET['t'];[/color]

      <snip>

      I'm pretty new to this. Is $_GET the same as $HTTP_POST_VARS ? If it is,
      why are there 2 ways of doing it?

      Andy

      Comment

      • Sacs

        #4
        Re: Begininger to PHP, requesting a little help

        >[color=blue]
        > <snip>
        >
        > I'm pretty new to this. Is $_GET the same as $HTTP_POST_VARS ? If it is,
        > why are there 2 ways of doing it?
        >
        > Andy
        >[/color]
        Hi Andy,



        Well, $_GET uses GET variables (visible on the url), $HTTP_POST_VARS
        uses POSTed variables (within a METHOD=POST form), so I think your
        question is whether $_GET and $HTTP_GET_VARS are the same.

        $HTTP_GET_VARS is used prior to PHP 4.1.0 and was not superglobal. Since
        then it is reccomended to use $_GET and $_POST etc which are superglobals.

        Apparantly... :-)

        Sacs

        Comment

        • Christopher A. Kelly

          #5
          Re: Begininger to PHP, requesting a little help

          I'm trying to pass a var called "u" in an url aka
          www.mysite.com/myscript.php?text=string&u=BOOL. I need it to be read
          as a bool so that a user could use 1,true,TRUE or 0,false,FALSE for
          the value. how can i do this?

          i have tried
          if(isset($_GET['u']) && $_GET['u'] == 1)
          {
          $text = strtoupper($_GE T['text']);
          }
          else
          {
          $text = $_GET['text'];
          }
          but 0,false,FALSE works and
          1 works however true,and TRUE doesn't. i am somewhat new to php and am
          sure it is something stupid that i have overlooked.


          Sacs <alan_nospam_@w ay.co.nz> wrote in message news:<XGbnd.363 4$9A.146031@new s.xtra.co.nz>.. .[color=blue][color=green]
          > >
          > > <snip>
          > >
          > > I'm pretty new to this. Is $_GET the same as $HTTP_POST_VARS ? If it is,
          > > why are there 2 ways of doing it?
          > >
          > > Andy
          > >[/color]
          > Hi Andy,
          >
          > http://www.php.net/manual/en/reserved.variables.php
          >
          > Well, $_GET uses GET variables (visible on the url), $HTTP_POST_VARS
          > uses POSTed variables (within a METHOD=POST form), so I think your
          > question is whether $_GET and $HTTP_GET_VARS are the same.
          >
          > $HTTP_GET_VARS is used prior to PHP 4.1.0 and was not superglobal. Since
          > then it is reccomended to use $_GET and $_POST etc which are superglobals.
          >
          > Apparantly... :-)
          >
          > Sacs[/color]

          Comment

          • Pedro Graca

            #6
            Re: Begininger to PHP, requesting a little help

            Christopher A. Kelly top-posted:[color=blue]
            > I'm trying to pass a var called "u" in an url aka
            > www.mysite.com/myscript.php?text=string&u=BOOL. I need it to be read
            > as a bool so that a user could use 1,true,TRUE or 0,false,FALSE for
            > the value. how can i do this?
            >
            > i have tried
            > if(isset($_GET['u']) && $_GET['u'] == 1)
            > {
            > $text = strtoupper($_GE T['text']);
            > }
            > else
            > {
            > $text = $_GET['text'];
            > }
            > but 0,false,FALSE works and
            > 1 works however true,and TRUE doesn't. i am somewhat new to php and am
            > sure it is something stupid that i have overlooked.[/color]

            true and TRUE do not work (???) because they always go to the else part
            of your if().


            I'd do that somewhat differently:

            if (isset($_GET['u'])) {
            switch (strtolower($_G ET['u'])) {
            case '1':
            case 'true':
            case 'y':
            case 'yes':
            $text = 'TRUE';
            break;
            default:
            $text = 'FALSE';
            break;
            }
            }
            --
            Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/
            == ** ## !! !! ## ** ==
            TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
            bypass the spam filter. I will answer all pertinent mails from a valid address.

            Comment

            Working...