Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Updating 1000’s records

$
0
0

I am trying to update my table using while loop, unfortunately it is only updating the first record. Why can I not update the whole 27000 records?

Thank you.

<?php

 $sql = "SELECT * FROM spammers ORDER BY spamID;";
 $res = mysql_query($sql);
 if(!$res) {
  trigger_error("Could not connect to the database!\n <br/>MySQL Error: " . mysqli_connect_error());
 }

 while ($rows=mysql_fetch_assoc($res)) {
  
    
    $sql = "UPDATE spammers 
      SET abc='". 5252 ."'
      WHERE spamID ='".$rows['spamID']."';";
    $res = mysql_query($sql);
    if(!$res) {
     die(" Could not query the database: <br/>". mysql_error() );
    }
 }

?>


Viewing all articles
Browse latest Browse all 13200

Trending Articles