-1
I have a PHP function (I read that it was recommended to make modifications to the PHP database and not JS)
function insertTable()
{
$name = 'nome';
$categoria = 'categoria';
$download = 1000;
$upload = 1000;
$magnet = 'magnet';
mysqli_query($connect, "INSERT INTO torrents(`Nome`, `Categoria`, `DownloadQuantity`, `UploadQuantity`, `Magnet`) VALUES ('".$name."', '".$categoria."', ".$download.", ".$upload.", '".$magnet."')");
}
And in my role in JS(she’s at action
one button) I want to call the function insertTable()
.
I read that PHP runs on the server and JS and runs on the browser, the only way I found it was when the PHP function is in a separate file, so using AJAX, but I want to do this with both functions in the same file.
@Sorry Miguel, I think Stack cut her off, I got :D
– Lucas Caresia
No problem, it was more for the joke.. I already deleted the comment
– Miguel
In the same file, only if you make the AJAX request to the file itself and treat it with PHP. However, as the file would receive both 'normal' requests and via AJAX, with PHP you will have to worry about not returning the HTML to when it is AJAX. Honestly, I see no reason to do this, not to mention that it leaves the organization of the project confused.
– Woss
I’m on my cell phone, so I can’t put the code in now. I use ajax to put a div on the page when pressing a button, and when that button is pressed I have to enter data into the database.
– Lucas Caresia