2

Currently i get the id with <?= $store->id ?> and it works fine

but i want to get the ID of mysql entry with

$id             =   $_GET['store_id'];
$query          =   "SELECT * FROM store WHERE id = '$id'";
$result         =   mysql_query($query);
$row            =   mysql_fetch_array($result);

or

$id             =   $_GET['$store->id'];
$query          =   "SELECT * FROM store WHERE id = '$id'";
$result         =   mysql_query($query);
$row            =   mysql_fetch_array($result);

and output with something like this <?php print $row["id"];?>

but it doesn't gives me the ID, it remains empty. What am I doing wrong? (I am aware working with mysql_... is not the best way, but that's not the problem now).

Da Andi
  • 21
  • 2

2 Answers2

2

If $store->id works fine for you, that means you're doing something wrong, and you defined $store earlier, IN your file. To get a param from the url, you need to use $_GET["param"]. If $_GET["store_id"] doesn't work then you didn't set an id in the url. If you want to get a param whose name is $store->id, then use $_GET[$store->id], but I don't think that's what you're looking for.

DO NOT use mysql_* functions. It takes only 2 minutes to change your code.

You do not need to select the current downloads to update it, you can do it via pure SQL: UPDATE store SET downloads = downloads + 1 WHERE id = ?

klenium
  • 2,468
  • 2
  • 24
  • 47
0

if you want to get ID from GET, your url must be like(Example)

http://www.mywebsite.com/mypage.php?store_id=1234 

Thus you will get

 $_GET['store_id'] // $_GET['store_id'] = 1234
Unni Babu
  • 1,839
  • 12
  • 16