I have a page which is dynamic and takes a URL variable then populates the page from a PHP database call based on the value of the URL variable e.g.
<a href="myPage?item_id=10">Show item</a>
Upon opening the page I grab the item_id from the URL and collect the data for printing e.g.:
$query = "select * from items where item_id = $_GET[item_id]";
$result = $mysqli->query($query);
$row = $result->fetch_array();
$title = $row['item_title'];
etc etc
My question is, can I grab a data variable from a link instead? e.g.
<a href="myPage" data-item_id="10">Show item</a>
The reason for asking is that I want to use a modal which of course cannnot read from a URL as it would be the parent URL.
Ideally I want to stick with PHP as the code is written, but if there's a simple jquery solution to bring the data in to populate the page then that would be ok too (I'd guess an ajax call)