exporting data by field size

From: Date: Sun, 20 Apr 2003 17:47:46 +0000
Subject: exporting data by field size
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144557@lists.php.net to get a copy of this message
Hi Thanks to Don and Peter for their previous replies. I've tried both your suggestions. I can't seem to get it right, even using sprintf(). The problem that I am having is that e.g. the National_Id field is VARCHAR(20) and the actual ID number is 13 characters. The data of the next column should only start after the 20 spaces (i.e. 13 for the ID and 7 blank). The other difficulty is that the field size for the rest of the columns are not the same. Any help or suggestions would be appreciated on how I could overcome this. Thanks Mohamed <PS. I have included the code I am using at the moment to create a tab delimited text file.> <? include "inc/db.php"; $qry=" SELECT National_Id,Learner_Alternate_Id,Alternative_Id_Type, Equity_Code,Nationality_Code,Home_Language_Code, Gender_Code,Citizen_Resident_Status_Code, Socioeconomic_Status_Code,Disability_Status_Code, Learner_Last_Name,Learner_First_Name,Learner_Middle_Name, Learner_Title,Learner_Birth_Date,Learner_Home_Address_1, Learner_Home_Address_2,Learner_Home_Address_3,Learner_Postal_Address_1, Learner_Postal_Address_2,Learner_Postal_Address_3,Learner_Home_Addr_Postal_C ode, Learner_Postal_Addr_Postal_Code,Learner_Phone_Number, Learner_Cell_Phone_Number,Learner_Fax_Number, Learner_Email_Address,Province_Code,Provider_Etqa_Id,Provider_Code, Learner_Previous_Lastname FROM learner_information"; if ($res= mysql_query($qry)) { $fp=fopen('PROV0120030420.txt', 'w'); while ($row = mysql_fetch_row($res)) { fputs($fp, "" .implode("\t", $row) ."\n"); } fclose($fp); } ?>

« previous php.general (#144557) next »