473,656 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

want to insert record from txt file as well as from another table

15 New Member
hi .........
i have two tables emp_company and at0310.
at0310 table having fields: ecardno,atdate, attime,IO,seria lno,cardrd and ecode.
into my text file ecardno,atdate, time,IO,serialn o,cardrd record available but ecode not comes from there. in my emp_compnay i have fields like ecode,ecardno,e tc . i want in my at0310 table ecode comes from emp_company and only those ecode should be stored into at0310
that matches with ecard with text file.... can you tell me any query .....
according to me select and insert needed but i cant place them in working order
plz help me out waiting for reply
thank you for taking the time to help me out!
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <?php
  3. $con=mysql_connect("localhost","root","root");
  4. if (!$con)
  5. {
  6. die('Could not connect: ' . mysql_error());
  7. }
  8. mysql_select_db('master',$con);
  9. //(1) Read the text file into a variable
  10. $file = "ATND.txt";
  11. $fp = fopen($file, "r");
  12. $data = fread($fp, filesize($file));
  13. fclose($fp);
  14. //(2) Then we can get rid of the tabs in there:
  15. $output = str_replace("\t"," ", $data);
  16. //(3) Then we explode it at every line break
  17. $output = explode("\n", $output);
  18. foreach($output as $var) {
  19. $tmp = explode(" ", $var);
  20. $ecardno = $tmp[0];
  21. $cluster = $tmp[1];
  22. $atdate = substr($tmp[1],0,6);
  23. $attime = substr($tmp[1],6,4);
  24. $IO = substr($tmp[1],10,1);
  25. $serialno = substr($tmp[1],11,5);
  26. $cardrd = substr($tmp[1],16);
  27. $ecode=$_POST['ecode'];
  28. //$sql = "INSERT INTO at0210 SET ecardno='$ecardno', atdate='$atdate',attime='$attime',IO='$IO',serialno='$serialno',ecode='$ecode'
  29. //select ecode from emp_company where ecardno.emp_company=ecardno.at0310";
  30. $sql = mysql_query("INSERT INTO at0310 ('$ecardno', '$atdate','$attime','$IO','$serialno','$cardrd'") ("SELECT ecode FROM emp_company WHERE ecode = '$_POST[ecardno]'")");
  31. mysql_query($sql);
  32. }
  33. echo "Done!";
  34. ?>
  35.  
Feb 24 '10 #1
0 1071

Sign in to post your reply or Sign up for a free account.

Similar topics

15
7379
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
1
8734
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware tblSoftware ------------------- ------------------ ---------------------- PID PName PID* SID* SID SWName --- ----- --- --- --- ------ 1 Thomas 1 1 ...
10
2114
by: teddysnips | last post by:
Application is a Work Tracking/Timesheet database. The increments of work are stored in the TimesheetItem table. This contains, inter alia, the Work Code, the Start and the Duration that the employee spent that day on a particular project. Some employees in the Network Support Department don't complete a standard 7.5 hour day for various reasons, so for every Network Support person I need to update these particular days with an amount...
8
9232
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record is entered, either from a form or from the table view of the table, when the record gets saved it immediately displays #DELETED# in all of the fields. However, if I close the form or table view and reopen the record has in fact been inserted. The...
8
6284
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with one-to-one relationship but on this occasion I must keep username/password details within a seperate table. Here's the basic specs and database schema: -------------------------------------------
3
1621
by: NuB | last post by:
I have an app that inserts records into a SQL db, I have a file that I'm reading to get the data out of, aka 'records', how can I determine of the record has been inserted into the database so i can log that?
4
2195
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). The way I have it now is ennumerating through my XML file and for each record, running an INSERT INTO SQL statement to put the values in the database. Is this going to be okay with 50 or so records (hitting the database with 50 or so INSERT...
0
4170
by: Peter Nofelt | last post by:
Hi all, ISSUE: ==================== In SQL 2005 (sp2) I get the following error when preforming a bulk insert with an associated xml format file: "Could not bulk insert. Unknown version of format file" Question:
0
2144
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include file="../Connections/conn.jsp" %> <% // *** Edit Operations: declare variables // set the form action variable String MM_editAction = request.getRequestURI(); if (request.getQueryString() != null && request.getQueryString().length() > 0) {
8
6480
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table using a code loop and an INSERT INTO query. About 800,000 records of raw text. Later, I can then loop through and parse these 800,000 strings into usable data using more code. The problem I have is that the conversion of the text file, using a...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.