The following code succesfully refreshes the #content div, but in doing so it clear the $name variable which is passed from a previous page. How can I reload the div without losing my variable? The following is the code in "thispage.php". Any help would be appreciated!

<html>
<head>

<script>
setInterval(function() {
    $('#content').load('thispage.php #content');
}, 3000);
</script>

</head>


<body>

<?php

include 'php/db.php';

$name = $_POST['name'];


echo '<div id="content">';

$ad= mysql_one_data("SELECT ad FROM tab1 WHERE name = '$name'");

echo 'Address ' .$ad. ' <br>';

echo '</div>';

?>



</body>
</html>

You could store the POSTed value in a session variable, just be sure you do not overwrite it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.