On clicking the text, JS function should get executed.
In HTML:
<html>
<body>
<a href="#" onclick="clickthis();">Table 1</a>
</body>
</html>
In PHP:
<?php
require 'dbconnect.php';
function clickthis(){
$search_table = "SELECT `table1` FROM `booktable` WHERE `table1`='booked';"
$query = mysqli_query($dbconnect,$search_table);
if(mysqli_num_rows($query)==0){
"INSERT INTO `booktable` (table1`) VALUES(`booked`)";
echo'Table booked successfully.';
?>
Have I placed the onclick
function correctly in HTML
?
Whenever I click on the text Table 1
, clickthis()
function should get executed but how can I achieve the result using PHP, JavaScript & HTML
.
P.S. I don't want to use button click & dbconnect.php
is external php file.