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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML 'id' and variable passing

Status
Not open for further replies.
Joined
Dec 29, 2003
Messages
4
Location
GB
Hi Everyone,

This is a stupidly simple question the answer to which - suprisingly - I can't find online.
Can some one give me an example of the use of "id" in a HREF link and how it is accessed in the called page, for instance passing a numeric variable to another page.

I am currently retrieving a number of rows from a database and presenting the data in a table. The last two cells of each table row contain a link (that is required to pass the numeric ID of that record) thereby allowing the record to be either:-
edited (linking to Parent_edit.php)
or viewed in greater detail (linking to Parent_Detail.php)

The alternative I considered was to create the cell, a form within the cell (not even sure that its possible!), a submit button within the form and use $_POST to pass the var. Each cell would require its own form to cope with the multiple record IDs and the two destinations!?
Would it work?

Many thanks to everyone in advance...

 
take the record and it has a field name of 'id'
Code:
while ($rows=mysql_fetch_array($result)){
    $id=$rows['id'];
    //all other variable/value pairs

    echo &quot;<a href=\&quot;someotherpage.php?id=$id\&quot;>Click here</a>&quot;;

then in the receiving 'someotherpage.php'

$id=$_GET['id'];

$sql=&quot;select * from table where id=$id&quot;;

$result=mysql_query($sql);

Is this what you are after?

HTH



Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Many Thanks seems to be just what I'm after! I knew it would be rediculously simple!!

Sorry to hear that you've been laid off, I've been there enough times for anyone in that position to get my sympathy.

The very best of luck in the New Year from Plymouth UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top