Can someone please help me figure out how to update multiple values all at one time? I have a database that holds the following values: item, part_number, price. I want to be able to update the part_numbers and prices all at once but I cannot find anything anywhere that tells me how to accomplish this. At first I stumbled across this script that seemed promissing:
$dbServer = \"myserver
$dbUser = \"user\";
$dbPass = \"password\";
$dbName = \"mydb\";
function ConnectToDb($server, $user, $pass, $database)
$s = @mysql_connect($server, $user, $pass);
$d = @mysql_select_db($database, $s);
if(!$s || !$d)
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
for($a=0; $a < $TheCount; $a++)
$SQL= \"UPDATE xc90 SET price=\'$prices[$a]\' WHERE part_number=\'$part_numbers[$a]\'\";
if ( mysql_query($SQL) )
echo(\"<P>Prices successfully updated!</P>\");}
echo(\"<P>Error updating prices: \" . mysql_error() . \"</P>\");
This works partially because it only updates the very last value to the right in both arrays and ignores all those before it.
I was also wondering if the is there a way to use the LOAD DATA IN FILE command to accomplish this task? I have a .txt file with the part_numbers and prices, but when I try to use the command LOAD DATA INFILE \"xc90.txt\" INTO TABLE xc90 (part_number,price) it appends the data as opposed to overwrite all records from the beggining with the new ones.
If someone could please help me I\'d be very appreciative. Thanks in advance for any help.
Update multiple records
No replies to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users