Basic PHP question

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-20-2004
Darryl
 
Posts: n/a
Default Basic PHP question

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




Reply With Quote
  #2 (permalink)  
Old 01-20-2004
Tyrone Slothrop
 
Posts: n/a
Default Re: Basic PHP question

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).
Reply With Quote
  #3 (permalink)  
Old 01-20-2004
Damir Mehmedovic
 
Posts: n/a
Default Re: Basic PHP question

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
>
>
>
>



Reply With Quote
  #4 (permalink)  
Old 01-20-2004
Savut
 
Posts: n/a
Default Re: Basic PHP question

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).



Reply With Quote
  #5 (permalink)  
Old 01-20-2004
Michael Meckelein
 
Posts: n/a
Default Re: Basic PHP question

> <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






Reply With Quote
  #6 (permalink)  
Old 01-20-2004
Darryl
 
Posts: n/a
Default Re: Basic PHP question

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
>
>
>
>



Reply With Quote
  #7 (permalink)  
Old 01-20-2004
Darryl
 
Posts: n/a
Default Re: Basic PHP question

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
> >
> >
> >
> >

>
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:03 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0