passing vars from page to page

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio

Tue Mar 18, 2003 5:08 am

Something like this should work:

<a href="http://www.someserver/somepage/<?php print(!empty($_REQUEST['level']) ? '?level='.$_REQUEST['level'] : ''); ?>">link name</a>

you can retrieve the level passed from another page by using one of the following:

You can then add this variable to your link by printing it where it needs to go. The above example tests to make sure the level is not empty, if it is, it will append an empty string to the url. If it is not empty, it will add a '?' and the level variable to the url.

The syntax of:
(test) ? (something) : (something else)
is just short hand for the if-then-else.

New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson

Tue Mar 18, 2003 5:18 am

Code: Select all

$level= $_GET["level"];
PHP+MySql= Love :)

Post Reply