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:s@g.com

 

name:XXX

office:

mobile:

email:s@g.com

 

name:XXX

office:

mobile:

email:s@g.com

 

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

please explain this

Link to comment
Share on other sites

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????

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.