|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
comparing data from text file to MySQL table
I was wondering if this is possible: Compare a row from a table to a row from a text file, and if that row is not in that text file, then delete it from that table, and move it to another one. Say for example I read in a text file and assign the following variables:
Code:
$fd = fopen ("d:active.txt", "r");
while (!feof ($fd)) {
$line= fgets($fd, 4096);
$MyArray=explode("|", $line);
$LastName=addslashes($MyArray[0]);
$FirstName=addslashes($MyArray[1]);
$MiddleName=$MyArray[2];
$SSN=$MyArray[3];
Then I have a table Active with the same fields: LastName, FirstName, MiddleName, SSN And an Inactive table exactly the same LastName, FirstName, MiddleName, SSN This text file is inserted into the Active table. The reason is, is that this text file is updated every 2 weeks, and only current data should be maintained, with an archive for old data. So again, I want to move data from the Active table to the Inactive table which is not present in the text file. Can anyone give me an idea on how to do this??? Hope all this makes sense, if not let me know and ill try to clarify it more. Thanks |
|
#2
|
|||||
|
|||||
|
RE: comparing data from text file to MySQL table
My answers implies that you add a field named 'flag' in your 'active' table. It has to be a boolean, so a char is perfect.
The goal is to mark each record from the active table to know that it is in the file, then copy inactive records to that table, then delete inactive records from 'active'. php Code:
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > comparing data from text file to MySQL table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|