It is currently Fri Mar 29, 2024 8:12 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: PHP SCRIPT PROBLEM
PostPosted: Sun Oct 29, 2006 8:08 pm 
Newbie
Newbie

Joined: Fri Oct 27, 2006 3:29 pm
Posts: 10
Hi I'm newbie in php programming. When I write in first script

Code:
<a href=script2.php?id=1>LINK</a>


and in second script

Code:
<?
echo $id;
?>

I think on the screen should write 1. Thats all.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 29, 2006 10:05 pm 
Getting Started
Getting Started

Joined: Wed Jun 07, 2006 1:34 am
Posts: 67
Variables listed after a '?' in a url can be accessed through the special '_GET' array variable.

For your example the code will look like this:
Code:
<?php echo $_GET['id'] ?>

Hope that helps.


Top
 Profile  
 
 Post subject: THANKS
PostPosted: Sun Oct 29, 2006 10:22 pm 
Newbie
Newbie

Joined: Fri Oct 27, 2006 3:29 pm
Posts: 10
Thanks for your help. Script now is working properly.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 4:23 pm 
Getting Started
Getting Started

Joined: Tue Sep 19, 2006 4:02 pm
Posts: 53
An addition to sparky's post, (because you are new, you may not know it either) if your URL has multiple parameters like:

Code:
<a href=script2.php?id=1&sort=asc&action=call>LINK</a>

you may access them all with the same way:

Code:
$_GET['id'];
$_GET['sort'];
$_GET['action'];


:)

_________________
Spiros


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011