1

I have this code on my Search page:

<a href="detail.php?id=<?php echo $ido;?>"STYLE="TEXT-DECORATION: NONE"><?php echo $nume;?></a>

and i also have a detail.php page. I need to get the $ido value from the URL so that I can use it in the detail.php page to retrieve information from the database.

The detail page has a URL like this: detail.php?id=17 , I need to get the value after the =, in this case 17, into a variable.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
user3772864
  • 53
  • 1
  • 1
  • 3
  • 2
    `$_GET['id']`? – alexn Jun 24 '14 at 21:35
  • I know its 6 years old. Im assuming TorrentTrader 3.0, the question highly relevant to torrents-details.php which I believe is what they are inquiring about. This script relies on $id throughout most files, so updating this script file will essentially break the backend functions and template files. Not advised if running TorrentTrader 3.0-svn. $id = $_GET['id'] is line 14 in the file I mentioned. – WLFree Apr 05 '20 at 00:07

3 Answers3

14

In your detail.php use: $id = $_GET['id']; you can then use $id around the rest of your page.

Kinnectus
  • 899
  • 6
  • 14
  • Sorry, Its been 2 years ago, I just wanted to ask! What if I have a url `anypage.php?tacker=123` - Should it be like `$id = $_GET['tracker'];` :/? – Flamur Beqiraj Jan 08 '17 at 02:15
  • Exactly right. But make sure your URL and `$_GET ['tracker']` use exactly the same word/spelling ("tracker") so it knows which URL parameter the script is referring to. – Kinnectus Jan 08 '17 at 21:19
0

You can also use $_SERVER['QUERY_STRING'];

But this will only fetch id=17

0

If still having problem then try:

  • To fetch integer value:

    $id = intval($_GET['id']);
    
  • To fetch string value:

    $name = strval($_GET['name']);
    
Syscall
  • 19,327
  • 10
  • 37
  • 52