• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AJAX Automatic PHP MYSQL_QUERY

ciachowski

Weird Person
Joined
Jun 17, 2009
Messages
90
Reaction score
0
Location
Poland
Greetings,

While working I came across a problem and I ask for your help to slove it.
I am trying to write AJAX/JS script that will dynamicly updating mysql queries and returns results to the PHP script. It means that I wanna make script that will displays variables from mysql_database without reloading page and the result variable will not be variable as string.
e.g. it's something like that: (I really don't know JS well, so I will write it in php-style)

AUTOMATIC QUERING THIS PART IN JS/AJAX SCRIPT {
$sql = mysql_query("...");
$sql1 = mysql_fetch_array($sql);
$result = $sql1['...'];
}

DISPLAYS RESULTS IN PHP SCRIPT {
echo $result;
}

I really don't know how to wrtie it, I have already googling so long time, and didn't find any good idea how to get point. The biggest problem is that I cannot receive result variable as string because I cannot use it anymore in any function e.g. if();.

Maybe someone of you will be able to help me
I am looking forward answers
 
Ahm, I am trying and it doesn't want to work, maybe could you post me here an example basing on my upper post example?. I really don't know what could I missing.

here is simple example how to use $.load:
Code:
<head>
<script type="text/javascript">
 $(document).ready(function() {
 $('#load').load('omg.html');
});
</script>
</head>
<body>
<div id="load"></div>
<body>
But even this code doesn't work lolz.
 
Last edited:
Basing on this page and content of there then I have to load jQuery first, OK I've already loaded it, but it doesn't work as early.
Here is page, which you posted before: .load() – jQuery API
Here is a short quote where is example - how to relase jQuery.load:
<!DOCTYPE html>
<html>
<head>
<style>
body{ font-size: 12px; font-family: Arial; }
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

<b>Footer navigation:</b>
<ol id="new-nav"></ol>

<script>
$("#new-nav").load("/ #jq-footerNavigation li");
</script>

</body>
</html>
Evenif I try like it is in the example it still doesn't work. Dunno why, on many pages I've found many other examples but nothing of them works.
Maybe I am wrong, but shouldn't I install somekind of addon to php or something other?.
 
Here you are my actualy try:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

<ol id="new-nav"></ol>

<script>
$("#new-nav").load("omg.html");
</script>

</body>
</html>
and content of omg.html is (sorry for destructive language) "KURWA MAĆ!".
If I am right then the script should display content of omg.html and reload it everytime I change content of omg.html file witout refreshing page.
 
Here you are my actualy try:

and content of omg.html is (sorry for destructive language) "KURWA MAĆ!".
If I am right then the script should display content of omg.html and reload it everytime I change content of omg.html file witout refreshing page.

No, it won't reload it as long as you don't make interval for AJAX to check it for example every 1 second.
 
Back
Top