| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() | how to display updated data after update? hello all, I am trying to lerarn how to update database. Everything is fine but after the update is done it is still showing the content which was before the update. if i put the browser off and on again there is no problem, it is showing the updated content. What can i do to show the updated content after pressing submit? Thanks PHP Code: instead of PHP Code: PHP Code:
__________________
Last edited by baris22; 11-09-2008 at 08:02 AM.
|
| | |
| | #2 (permalink) |
| NamePros Regular Join Date: Jul 2007 Location: UK
Posts: 394
![]() ![]() ![]() ![]() ![]() ![]() ![]() | I would move the update code to before the select query: Code: <?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Check if button name "Submit" is active, do this
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]' WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}
}
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
__________________ |
| | |