NYCPHP Meetup

NYPHP.org

[nycphp-talk] newbie - square one

-sry sryBoston at hotmail.com
Tue Dec 2 07:36:37 EST 2003


Okay, here's a really, REALLY basic question. I always seem to
get the high-level stuff and miss the basics (kinda like Algebra
stumps me even with a calculator but Calculus I do in my head :*)

I've RTFM at php.net - very nice docs, like the searchability and
index. Good online reference book. Alas, I want to do my very
first PHP page--well, okay, not the first, I did a "Hello world" and
phpinfo.php and those went fine and told me a bunch about my
installation, all well and interesting, but now I want to do something
I can actually USE.

Let's say I have a page somepage.html and it has an onLoad(params) 
function in the BODY tag that currently calls some JavaScript
funciton. Elsewhere on the page, I have a bunch of links to a PHP version 
of somepage.html and want to pass it different "params" for each of the
links, each of which will "convert" the JavaScript/HTML behavior into 
PHP/HTML behavior and do something different with the onLoad()
depending on which "params" value is clicked by the user.

Never mind if this how to actually do it - I know I should just start
with a php page, but I want to do it this way to LEARN, okay?
If I change too many things at once, I will get lost on what is 
actually happening; my debugging habits are old and fixed. I can
only change one thing at a time or I miss the problem completely.

So for this link, I know I would put "somepage.php?params=value"
cause this is the syntax of a query string and how one passes params
via HTTP, but.... in the somepage.php, what do I do? Where do 
I put the first <?php ... ?> stuff? How do I extract "params" as
a variable and get its user-selected value? 

The documentation seems to imply I would just put:

<?php
$params=value;
...
?>

and that the query string will have "created" the variable $params
and somehow PHP will "know" what's in the query string and
"value" will be defined...really? I don't have to extract some 
ENV-VAR like old-fashioned CGI processing?

And since the assignment I want to do is in the BODY tag, how
do I write the body tag with a PHP variable? like this:

<?php
$params=value;
echo "<BODY onLoad=\"myJavaScriptFunc(\" + $params + \");\" ";
?>

That didn't seem to do it for me so I must have misread or
misunderstood the docs. Enlighten my ignorant self, someone?

-sry
----------------------------------------------------------------------
Sarah R. Yoffa
http://www.sarahryoffa.com/
sryBoston at hotmail.com
"Stupid rules are meant to be changed, not broken."
      [-sry on sci.space.shuttle, c. 1993]
----------------------------------------------------------------------



More information about the talk mailing list