Reputation: 23
I am trying to pass the id to another page so it can be deleted when the link is pressed. the Id is displaying in the url but I am having trouble, getting hold of the id, I have tried: to use the pars url but it is not working.
parse url
echo parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY);
link
<p><a href="<?php echo 'example.php/'.$item->getproductid(); ?>">Delete</a></p
Upvotes: 1
Views: 40
Reputation: 34416
It is because your URL needs to be corrected to add a query string, starting with a ?
and an identifier
<a href="<?php echo 'example.php/?foo='.$item->getproductid(); ?>">
Now you can either parse the URL (not necessary and unnecessarily complex for this action) or get the value from the GET array:
$_GET['foo']; // is the id in $item->getproductid()
Upvotes: 1