We help IT Professionals succeed at work.
Get Started

Refresh a value from a table in JavaScript

Ahmad Jaber
Ahmad Jaber asked
Last Modified: 2020-03-02
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

<?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>

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

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

Open in new window

<?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>";} ?>

Open in new window

Maybe my method is not the right one, so if you can help me it would be nice.
Watch Question
Responsable Multimédia
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE