W tym celu użyj Ajax:
Dodaj ten kod do strony głównej, na której chcesz wyświetlić dane tabeli
<html>
<head>
<script>
function dashboard() {
var query_parameter = document.getElementById("name").value;
var dataString = 'parameter=' + query_parameter;
// AJAX code to execute query and get back to same page with table content without reloading the page.
$.ajax({
type: "POST",
url: "execute_query.php",
data: dataString,
cache: false,
success: function(html) {
// alert(dataString);
document.getElementById("table_content").innerHTML=html;
}
});
return false;
}
</script>
</head>
<body>
<div id="table_content"></div>
</body>
</html>
W table_content div dane pochodzą z execute_query.php strona zostanie załadowana bez jej odświeżania.
execute_query.php
$user_name = $_POST['parameter'];
$query="SELECT * from info where name=$user_name";
$result=mysql_query($query);
$rs = mysql_fetch_array($result);
do
{
?>
<table>
<tr>
<td><?php echo $rs['city']; ?></td>
<td><?php echo $rs['phone_number']; ?></td>
</tr>
</table>
<?php
}while($rs = mysql_fetch_array($result));