troubleshooting Question

Refresh a value from a table in JavaScript

Avatar of Ahmad Jaber
Ahmad JaberFlag for Côte d'Ivoire asked on
DatabasesJavaScriptPHP
8 Comments1 Solution82 ViewsLast Modified:
Hi all,
I am asking for your help on a small project that I am implementing, that of updating a value in my database.
Since there is a value to enter in a textbox, I cannot load everything (well I think) on another page and refresh every second ...
Here is my complete code and I can't refresh Enchere_Max

Sans-titre.png
index.php
<?php try{$Stat = $pdo->query("SELECT * FROM tb_shop_enchere"); while($data = $Stat->fetch(PDO::FETCH_ASSOC)) { $MyId = $data["NumId"]; ?>

<div id="Enchere_<?php echo $MyId; ?>"></div>

<script>
$(document).ready(function() {
	setInterval(function() {
		$('#Enchere_<?php echo $MyId; ?>').load('refresh.php');
	}, 1000);
});
</script>

<?php }}catch(PDOException $e){echo "<div class='alert alert-danger'>".$e->getMessage()."</div>";} ?>

refresh.php
<?php try{$Stat = $pdo->query("SELECT * FROM tb_shop_enchere WHERE NumId = '".$MyId."'"); while($data = $Stat->fetch(PDO::FETCH_ASSOC)) { ?>

<?php echo $data["Enchere_Max"];?>

<?php }}catch(PDOException $e){echo "<div class='alert alert-danger'>".$e->getMessage()."</div>";} ?>
Maybe my method is not the right one, so if you can help me it would be nice.
ASKER CERTIFIED SOLUTION
Ahmad Jaber
Responsable Multimédia

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros