I've got a question concerning JQuery in combination with PHP and MySQL. This is the scenario.
I've got a div that displays the amount of points of a user, however due to certain actions on the website the amount of points get altered. Now I've seen plenty of scripts that use external files which contain queries to retrieve the wanted information from the database. However, that would mean I'd have to pass on a value, sensitive value in this case since I'd be first of all give someone access to a certain ID I don't want to the person to see and it leaves someone else open to testing out other IDs (even if I don't print any information on that particular page, I don't want anyone executing unnecessary queries; not to mention a possible SQL injection, although I'm well protected against those).
So to summarize, and I've searched on this website and haven't found exactly what I needed, how can I do this?
<div id="content">
<?php
/*
this contains my sql queries and
retrieves the relevant information I need.
*/
?>
</div>
<script>
Use Jquery to update the contents of the div containing id: 'content',
but without using external files and just re-run the query whenever
there is a change.
</script>
I'm not asking for specific tutorials, but a kick in the right direction would be appreciated. NodeJS isn't an option, I only have access to Jquery/Javascript for this task, so references to relevant functions would be more than welcome.
Thanks in advance!
its IMPOSSIBLE to do that without an external SERVER SIDE coded page.
you have to use ajax like this :
$.post('pagetthatrunsqueryandreturnscontent.php',
{
var : value//if you need to send a value to the page if else set to null or {}
},
function(data){
$('#content').html(data);//putting the data in the div
});