I'm trying to assign a field called 'uniqueid' to each row present in my database. There are roughly 188,000 rows available.
Here is the code I am using:
$connection = mysql_connect("localhost","root","root");
mysql_select_db("comics",$connection) or die ("Database not found");
$query = mysql_query("select * from comic_issues");
if ($query){
$rows = mysql_num_rows($query);
foreach($rows as $row){
$str = strtolower($row['series'].$row['volume'].$row['issue']);
$str = preg_replace('/[^A-Za-z0-9]/', '', $str);
$update = "update comic_issues set uniqueid='" . $str . "' where id='" . $row['ID'] . "'";
mysql_query($update);
exit();
}
}
What is happening is that every row gets updated with the same uniqueid, which seems to be a different value each time I run the script.