I am trying to get the value of an anchor tag using PHP code. When I click the hyperlink, however, I am not getting the value.<a href = ' '> value
My code is as follows:
<?php
$gettingevents = "SELECT event_name FROM events";
$resultgettingevents = mysqli_query($con,$gettingevents) or die(mysqli_error($con));
while($getevents = mysqli_fetch_assoc($resultgettingevents)){
$gettablenames = $getevents['event_name'];
echo '<a id="events" href="registeredevents.php?tablename='.$getevents['event_name'].'">'.$gettablenames.'</a>';
if(isset($_GET['tablename'])){
$clickedtable =$_GET['tablename'];
echo "the clicked table is ".$clickedtable;
}else{
echo "";
}
}
?>
I am getting the following error:
undefined index: tablename in
What is wrong with my code? How can I get the hyperlink value?
why you used '$clickedtable =$_GET['tablename']' this line at the end of while loop? –
ermmm to get the hyperlink value... – Madhi
you also need to remove the space in 'registeredevents.php?tablename =' - besides putting the GET array first and checking if it's set/not empty –