Jump to content

Reading data from text file and insert into database using php


thenature4u

Recommended Posts

culd you explain the code for insertind data from text file into mysql database using php.

ex: data.txt this file contains below details.

name:XXX

office:

mobile:

email:[email protected]

 

name:XXX

office:

mobile:

email:[email protected]

 

name:XXX

office:

mobile:

email:[email protected]

 

these details insert into database table structure is( name office mobile email)

please explain this

Hi there,

 

This is basic notepad file of a User table and records that are inputed auto via phpmyadmin but includes the creation of the tables as well.... You should hopefully be able to reverse engineer it...

 

-- phpMyAdmin SQL Dump
-- version 2.10.1
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generation Time: Feb 05, 2008 at 07:59 PM
-- Server version: 5.0.45
-- PHP Version: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

-- 
-- Database: `woodside`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `user`
-- 

CREATE TABLE `user` (
  `id` int(4) NOT NULL,
  `FirstName` varchar(25) NOT NULL,
  `LastName` varchar(25) NOT NULL,
  `Age` int(3) NOT NULL,
  `Hometown` varchar(25) NOT NULL,
  `Job` varchar(25) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `user`
-- 

INSERT INTO `user` (`id`, `FirstName`, `LastName`, `Age`, `Hometown`, `Job`) VALUES 
(1, 'Peter', 'Griffin', 41, 'Quahog', 'Brewery'),
(2, 'Loise', 'Griffin', 40, 'Newport', 'Piano Teacher');

 

Unless i have gotthe wrong end of the stick here????

Archived

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

×
×
  • Create New...

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.