I can't call PHP-function in Javascript. My code:
function clearDatabase(){
$str_sql_query = "TRUNCATE TABLE categories";
if (!$result = mysql_query($str_sql_query, $link))
{
echo "<br>Bad request<br>";
exit();
}
echo "All deleted!";
}
echo "<script type=\"text/javascript\">
function clickClearButton()
{
<?php clearDatabase(); ?> //This function don't call
}
</script>";
I already tried "<?php clearDatabase(); ?>"
, \"<?php clearDatabase(); ?>\"
. clearDatabase();
.
What i doing wrong?
Thank you.