Jump to content

Archived

This topic is now archived and is closed to further replies.

jana

how to fetch the below data into mysql

Recommended Posts

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

[color=red]12062006[/color][color=green]0920[/color][color=blue]1004[/color]
1206200622121004
1206200608161156
1206200620451156

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

[color=red]12062006 as c_date[/color]
[color=green]
0920 as I_Time[/color]
[color=blue]
1004 as empcode.[/color]

can anyone solve this?



Share this post


Link to post
Share on other sites
look at substr() to split string
http://no.php.net/manual/en/function.substr.php

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

Share this post


Link to post
Share on other sites
can u tell me how to open a text file in php and how to fetch each line.

Share this post


Link to post
Share on other sites
[quote author=jana link=topic=109523.msg441586#msg441586 date=1159266943]
can u tell me how to open a text file in php and how to fetch each line.
[/quote]
[url=http://www.php.net/file]file()[/url]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.