Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML and PHP Parameters 2

Status
Not open for further replies.

RPGguy

Programmer
Jul 27, 2001
73
US
I am creating a website using HTML, PHP and mySQL. I can pass a parameter from 1 page to another using the URL but I don't know how to retrieve it in HTML or PHP. An example of the simpleist method would be great.

Also, I would like to make the column headings of a list page into buttons that would resequence the screen when pushed. Again, an example would help.

Thanks in advance. I love this site!

Scott
 
o.k
lets say u have a url like this:
(query string)
in test.php:
<?
echo $_GET['id'];
?>

and bout ur second problem, can u be a bit more clearer???

Known is handfull, Unknown is worldfull
 
Thanks but I'm confused. Once I GET the parameters how do I reference them? I've tried passing 2 variables(varTable & varSeq), doing GET's on both then tried to build a generic SQL:
$query = &quot;SELECT * FROM &quot; & '.$varTable.' & &quot; ORDER BY &quot; & '.$varSeq'&quot;;

My manuals don't touch on this seemingly simple topic and it's very frustrating.

The second part of my original question meant replacing the column headings I use in my list with buttons. If a user clicked on say a 'City' button I want to change a generic SQL statement with 'ORDER BY CITY' and regenerate the page.

Thanks again.
 
Hmmm, what wasn't clear in what vbkris just told you. Once again, using your example:
Code:
$query = &quot;SELECT * FROM &quot; . $_GET['varTable'] . &quot; ORDER BY &quot; . $_GET['varSeq'];
The & signs in your query string were erroneous, in php you concate with .

Using superglobal arrays, you pick up variables from previous page:

$_GET for the url passed variables
$_POST for the form method post variables
$_SESSION for the session variables and
$_COOKIE for the cookies

The syntax is always the same and was explained above by vbkris and me. Note that superglobals became available in php 4.1.0, older versions should use $HTTP_GET_VARS. Consult for more information or ask in the php forum: forum434
 
yeah, it must work...

Known is handfull, Unknown is worldfull
 
Still having trouble. Here is the URL


Here is my code:
$query = &quot;SELECT * FROM &quot; . $_GET['varTable'] . &quot; ORDER BY &quot; . $_GET['varSeq'];

print $query;

Here is the print result:
SELECT * FROM ORDER BY

The GET is not picking up the value.

Thanks again for your help.
 
Did you check your php version? For versions before 4.1.0 $_GET does not exist and $HTTP_GET_VARS must be used. You can get the full contents of the $_GET array by adding this code:

echo '<pre>';
print_r($_GET);
echo '</pre>';
 
Try this:

Code:
$table = $_REQUEST[&quot;varTable&quot;];
$seq = $_REQUEST[&quot;varSeq&quot;];

$qry = &quot;SELECT * FROM $table ORDER BY $seq&quot;;

... and so on ...

Good Luck §;O)


Jakob

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top