I am trying to create a script that allows for multiple fields to be updated in a mysql database at once. Here’s the script I wrote to update one at a time, however with over 50,000 records. It’s not efficent for me to go through and update them all one at a time, I’d like to update all of them at once and process the update using a form.
How can I do this?
Here is my current code:
[php]// function will hide entry from search results
if($_POST[‘action’] == ‘update’) {
$id = $_POST[‘id’];
$title = preg_replace("/&(?![#0-9a-z]+;)/i", “&”, $_POST[‘title’]);
$artist = preg_replace("/&(?![#0-9a-z]+;)/i", “&”, $_POST[‘artist’]);
if (mysqli_connect_errno()) { echo “Failed to connect to MySQL: " . mysqli_connect_error(); }
$query = “UPDATE songlist SET title=’”.$title.”’, artist=’".$artist."’ WHERE id=’".$id."’";
mysqli_query($con,$query);
// echo "Edited ".$title. " - ".$artist;
header(’/request.php’);
mysqli_close($con);
}
[/php]