Hey all,
The following script displays record data, and updates that data just fine,
however you have to reload the page to see the updates.
How might I alter so that the updated data returns in real time without refreshing the page?
[code=php]<?php
require_once (‘../mysql_connect.php’);
mysql_select_db (‘bike_shop’);
$rows_per_page = 1;
$sql = “SELECT * FROM catalog”;
$result = mysql_query($sql);
$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);
$screen = $_GET[‘screen’];
if (!isset($screen)) $screen = 0;
$start = $screen * $rows_per_page;
$sql = “SELECT id,description FROM catalog “;
$sql .= “LIMIT $start, $rows_per_page”;
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
for ($i = 0; $i < $rows; $i++) {
$record=mysql_result($result,$i,”id”);
$descripton=mysql_result($result,$i,”Description”);
$disp_count=($screen+1);
echo ”
<form action=” method=’post’>
<div align=’center’>
<table width=’57%’ bordercolor=’#C0C0C0′>
<tr>
<td width=’14%’ align=’right’><b>Description:</b></td>
<td colspan=’2′><textarea name=’description’ rows=’5′ cols=’60’>$descripton</textarea></td>
</tr>
<tr>
<td width=’14%’ align=’right’ valign=’top’></td>
<td align=’center’><input type=’submit’ value=’Submit’ name=’submit’></td>
</tr>
</table></div>
</form>”;
if (isset($_POST[‘submit’])) { // Handle the form.
$Description = $_POST[‘description’];
$update=” UPDATE catalog SET Description=’$Description’ WHERE id = ‘$record’ “;
$result=mysql_query($update) or die (“Query failed – updating Products”); // Run the query. ;
}
}
echo “<p align=’center’><table ><tr><td>n”;
if($screen > 0)
{
$prev = $screen-1;
$prevlink = “<a href=””.$url.”?screen=$prev”>Previous</a> || “;
}
else
{
$prevlink = “Previous || “;
}
echo $prevlink;
if($screen < $pages-1)
{
$next = $screen+1;
$nextlink = “<a href=””.$url.”?screen=$next”>Next</a>”;
}
else
{
$nextlink = “Next”;
}
echo $nextlink .”<br>”;
echo “</td></tr></table></p>”;
?>