traderjean Posted January 7, 2012 Share Posted January 7, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/254556-jquery-update-database-table/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.