At 23:10 17/01/01 -0500, andrew wrote:
>How can I pass an anchor tag attribute to a page?
>e.g. If I want to echo "1" on page_two:
>
>
>page_one.php contains:
>
><a href="page_two.php" > <? $id="1"?>click</a>

All you're doing there is setting the variable id to "1". You're not even 
printing it.

>page_two.php contains:
>
><? echo($id); ?>
>
>but page_two is coming up blank after a delay... what I am doing wrong?

Alot :)

You have to use forms if you want to pass variables along between pages, 
unless you use cookies or PHP4 sessions (which use cookies).

You could use standard URL anchors for moving between pages and passing 
variables along - they'd have to be GET type. e.g.

page_one.php would be: (although it could be shortened or formatted 
differently)

<?php
// Below: Set the variable id to 1.
$id  = "1";
// Below: append the id as a GET variable to the url.
echo "<a href=\"page_two.php?id=$id\"> click </a>";
?>

and page_two.php would be:

<?php
// Below: Make sure that id was actually appended to the URL in page_one.php
if(isset($HTTP_GET_VARS["id"]))
{
// Below: If it was there, set it as a variable
$id = $HTTP_GET_VARS["id"];
echo "$id";
}
?>

I suggest you read through the PHP manual some more, especially the section 
on Variables, and the sub-section "Variables from outside PHP" 
(http://www.php.net/manual/en/language.variables.external.php). It would 
also be a good idea to read through some tutorials from some PHP websites, 
such as:

http://www.phpbuilder.com/
http://www.phphelp.com/

Those two should also have some links to other sites.

Good luck!

Angus.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to