Jump to content


Photo

how to fetch the below data into mysql


  • Please log in to reply
5 replies to this topic

#1 jana

jana
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts
  • LocationIndia

Posted 26 September 2006 - 10:24 AM

I am new to php and i want to insert a text file into mysql. i hav created the table temp_table

Temp_Table

c_date          varchar(10)
I_time            varchar(4)
O_Time          varchar(4)
empcode      varchar(7)

and the text file contains the data like this

1206200609201004
1206200622121004
1206200608161156
1206200620451156

and i want to split each line and insert into the table by 

12062006 as c_date

0920 as I_Time


1004 as empcode.


can anyone solve this?




Jana

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 26 September 2006 - 10:27 AM

look at substr() to split string
http://no.php.net/ma...tion.substr.php

and explode() to get each line by exploding \n (or \r)
http://no.php.net/ma...ion.explode.php

#3 jana

jana
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts
  • LocationIndia

Posted 26 September 2006 - 10:35 AM

can u tell me how to open a text file in php and how to fetch each line.
Jana

#4 prabhuraman

prabhuraman
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 26 September 2006 - 11:01 AM

hello jana, muself prabhuraman i am too new to php, can we both join and study php together...

#5 jana

jana
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts
  • LocationIndia

Posted 26 September 2006 - 11:34 AM

yes sure
Jana

#6 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 26 September 2006 - 12:24 PM

can u tell me how to open a text file in php and how to fetch each line.

file()




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users