Jump to content

jQuery update database table


traderjean

Recommended Posts

Hello everyone!

I created some code to retrieve a MySql table via PHP. It works fine :

THIS IS trade-brief.php
<table>
<th>Statut</th>
<th>Sous Jacent</th>
<th>Sens</th>
<th>Entrée</th>
<th>Stop</th>
<th>Objectifs</th>
<?php

$datab_name = $wpdb->prefix . "trades";
$alltrades = $wpdb->get_results( 
"
SELECT *
FROM $datab_name
WHERE status = 'En cours'
	AND tk_live = 0
OR status = 'En attente'
	AND tk_live = 0
"
);

foreach ( $alltrades as $alltrades ) 
{	$sens = $alltrades->sens;
$entree = $alltrades->entree;
$sortie = $alltrades->sortie;
?> <tr>
<td><?php echo $alltrades->status;?></td>
<td><?php echo $alltrades->sous_jacent;?></td>
<td><?php echo $alltrades->sens;?></td>
<td><?php echo $entree;?><br><?php echo $alltrades->date_entree;?></td>
<td><?php echo $alltrades->stop;?></td>
<td><?php echo $alltrades->objectif1;?>
	<br><?php echo $alltrades->objectif2;?>
	<br><?php echo $alltrades->objectif3;?></td>
</tr>
<?php }

?>
</table>

 

now I want this to be update automatically. So used jQuery and following script :

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {

$("#loaddiv").fadeOut("fast").load("/tk/wp-content/themes/twentyeleven/trades-brief.php").fadeIn("slow");

var refreshId = setInterval(function() {
$("#loaddiv").fadeOut("fast").load("/tk/wp-content/themes/twentyeleven/trades-brief.php").fadeIn("slow");
}, 5000);

$.ajaxSetup({ cache: false });

});

</script>

 

the script seems to work (half) as I see the table titles (TH) but MySQL table content does not load in it.

Seems like the jquery refresh is not querying the database. I use wordpress so my code is a little different than standard php.

 

So question is :

Where is the conflict. I'm not a pro, don't really understand why it doesn't load my php code properly;

 

Thanks a lot for any help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.