We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Update multiple records with single action

Hello there
I have question about how to update multi row in MySQL database, I used while function but this do the job with more time and no indecator when to finish the work,
is there any efficient way to update like 1000 row with one button and make indecator to see the progress of work ?

I used this code

if(isset($_POST['update'])) {
   $update=$_POST['update'];
   $sql = "SELECT user FROM users";
$query = mysql_query($sql)or die(mysql_error());
while($found = mysql_fetch_array($query))
    {

$psn = New psn(); 
$psnUser = $psn->get_jid($found['user']); 
$gold = $psnUser [0]['gold'];
$silver = $psnUser [0]['silver'];
$bronze = $psnUser [0]['bronze'];
$score = $psnUser [0]['points'];
$level = $psnUser [0]['level'];
$total = $psnUser [0]['total'];
$progress= $psnUser[0]['progress'];
$games=$psn->get_games($psnUser['jid']);
$totalgames= $games['totalGames'];

$sql="UPDATE `users` SET  `level` =  '$level',
`bronze` =  '$bronze',
`silver` =  '$silver',
`gold` =  '$gold',
`total` =  '$total',
`score` =  '$score',
`progress` =  '$progress',
`totalg` =  '$totalgames' WHERE  `user` = '$found[user]' LIMIT 1 ";

 $result=mysql_query($sql)or die(mysql_error());

echo $found['user'];
echo "  ....... DONE <br>";
}
2
Contributors
4
Replies
1 Month
Discussion Span
5 Months Ago
Last Updated
7
Views
OsaMasw
Junior Poster
155 posts since Jan 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This function may do the trick: http://php.net/ob_implicit_flush

pritaeas
Posting Prodigy
Moderator
9,261 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,454
Skill Endorsements: 86

can you specify more ? with code example

OsaMasw
Junior Poster
155 posts since Jan 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

See the link.

pritaeas
Posting Prodigy
Moderator
9,261 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,454
Skill Endorsements: 86

I've saw the link and try the examples, all of them update the counter or items then appears once with message complete :(
I need to update one by one and see the result for each result.

OsaMasw
Junior Poster
155 posts since Jan 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.2917 seconds using 2.69MB