This is a discussion on Basic PHP question within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Greetings, I have a page called test.php. I want to call the same page but pass a variable to ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Greetings,
I have a page called test.php. I want to call the same page but pass a variable to it so that data on the page (retrieved from mysql database ) changes. So, can I have inside test.php a call to test.php with a variable ? thanks, Darryl |
|
|||
|
On Tue, 20 Jan 2004 09:34:52 -0600, "Darryl" <darryl@osborne-ind.com>
wrote: >Greetings, >I have a page called test.php. I want to call the same page but pass a >variable to >it so that data on the page (retrieved from mysql database ) changes. > >So, can I have inside test.php a call to test.php with a variable ? Of course! It would go something like this: <html> <head>title</head> <body> <?php if ($somevar) { # make data call here returning some data ?> This is page with somevar. <?php } else { ?> This is without somevar. <php } ?> </body> </head> $somevar could be sent by post (form) or get (query string). |
|
|||
|
Hi Darryl,
you can call the page directly with variables like: test.php?your_var=1&another_one=testing or you can eventually use some form: echo "<form action=\"test.php?your_var=1\" method=\"post or get\">"; instead of \"test.php?your_var=1\", you can try also the $_PHPSELF variable and use the fields (hidden or normal) from your form.. Lot of fun.. Greetz, Damir "Darryl" <darryl@osborne-ind.com> wrote in message news:97ydnQujtdtr1JDd4p2dnA@news.ruraltel.net... > Greetings, > I have a page called test.php. I want to call the same page but pass a > variable to > it so that data on the page (retrieved from mysql database ) changes. > > So, can I have inside test.php a call to test.php with a variable ? > > thanks, > Darryl > > > > |
|
|||
|
Your code is deprecated
use this one below <html> <head>title</head> <body> <?php if ($_REQUEST["somevar"]) { # make data call here returning some data ?> This is page with somevar. <?php } else { ?> This is without somevar. <php } ?> </body> </head> Savut "Tyrone Slothrop" <ts@paranoids.com> wrote in message news:najq00dtiop6sectf27kthul5oefsv36ep@4ax.com... > On Tue, 20 Jan 2004 09:34:52 -0600, "Darryl" <darryl@osborne-ind.com> > wrote: > > >Greetings, > >I have a page called test.php. I want to call the same page but pass a > >variable to > >it so that data on the page (retrieved from mysql database ) changes. > > > >So, can I have inside test.php a call to test.php with a variable ? > > Of course! It would go something like this: > > <html> > <head>title</head> > <body> > <?php if ($somevar) { > # make data call here returning some data > ?> > This is page with somevar. > <?php } else { ?> > This is without somevar. > <php } ?> > </body> > </head> > > $somevar could be sent by post (form) or get (query string). |
|
|||
|
> <html>
> <head>title</head> > <body> > <?php if ($somevar) { > # make data call here returning some data > ?> > This is page with somevar. > <?php } else { ?> > This is without somevar. > <php } ?> > </body> > </head> > > $somevar could be sent by post (form) or get (query string). I would recommend that you use the $_POST['somevar'] or respective the $_GET['somevar'] vars to read your parameter from the header. Of course, Tyrone sample is good and work perfekt, but also if you start php coding, learn how to use parmeter in a more secure way. You can build a link to parse a varialbe to your page: echo '<a href="test.php?var=' . $value . '">sent var</a>'; if (issset($_GET['var'])) echo $_GET['var']; More detail information www.php.net/manual/en/ Michael |
|
|||
|
One more question then.
say I have defined: $adj = -60; and then in a loop I do: $adj = $adj - 30; then I want to have something like: -30px how do I convert to string and concatinate the px on the end? I still need $adj to be numeric so I can subtract from it on the next loop iteration. thanks, Darryl "Darryl" <darryl@osborne-ind.com> wrote in message news:97ydnQujtdtr1JDd4p2dnA@news.ruraltel.net... > Greetings, > I have a page called test.php. I want to call the same page but pass a > variable to > it so that data on the page (retrieved from mysql database ) changes. > > So, can I have inside test.php a call to test.php with a variable ? > > thanks, > Darryl > > > > |
|
|||
|
Nevermind, I figured it out.
strval() is my friend. "Darryl" <darryl@osborne-ind.com> wrote in message news:jOCdnc-toMT4P5DdRVn-hw@news.ruraltel.net... > One more question then. > say I have defined: > $adj = -60; > > and then in a loop I do: > $adj = $adj - 30; > > then I want to have something like: > -30px > > how do I convert to string and concatinate the px on the end? > I still need $adj to be numeric so I can subtract from it on the next > loop iteration. > > thanks, > Darryl > > > "Darryl" <darryl@osborne-ind.com> wrote in message > news:97ydnQujtdtr1JDd4p2dnA@news.ruraltel.net... > > Greetings, > > I have a page called test.php. I want to call the same page but pass a > > variable to > > it so that data on the page (retrieved from mysql database ) changes. > > > > So, can I have inside test.php a call to test.php with a variable ? > > > > thanks, > > Darryl > > > > > > > > > > |