Link to home
Start Free TrialLog in
Avatar of NeoAshura
NeoAshuraFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP MYSQL IMPORT EXCEL DATA

Hi Experts,

I have an excel data file with mobile numbers, which have leading zero's when i export this into mysql it takes the leading zeros off..

I have tried the following: Formatting the mobile number to custom and using 00000000000 so it looks like 07777777777 but that did not work still strips off the leading zero.

i also tried changeing the format of the column to text but that still did not work im guessing mysql changes the formatting back to "general" which then strips out the leading zero's.

Do you have any ideas??

Avatar of Greg Alexander
Greg Alexander
Flag of United States of America image

You need to change your cellphone field type to float instead on INT... or let me ask what the field type is now?
Avatar of NeoAshura

ASKER

it is varchar now. ill try it as float
ASKER CERTIFIED SOLUTION
Avatar of AnuarJamlus
AnuarJamlus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
using the phpmy admin import tool for excel files.
Untitled.png
I would try to save the spreed sheet to CSV and then try to import as CSV.
ive tried that as well,

all the data ends up in one column
like so...
Untitled.png
Hmm that it semicolon separated, did you set that when you imported instead of commas
here is how it is set out..
Untitled.png
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AnuarJamlus
AnuarJamlus

When you do the file import what are you entering on the following fields?

Fields terminated by:
Fields enclosed by:
Fields escaped by:
Lines terminated by:
you get my last message
nvm I see
what do you mean ray prepend? A?

here is the stripped down datasheet.


Untitled.png
prepend:

If the number is 0117033565001, you do something like this:
$text_number = '0117033565001';
$db_number = 'A' . $text_number;

Then when you recover the number out of the data base you use substr() to declop the leading "A"
SOLUTION
Avatar of Vimal DM
Vimal DM
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
a stripped-down copy of the spreadsheet - we only need a few columns and rows

Instead of a picture of an empty spreadsheet, can you please post some of the actual data?  You can upload XLS files here at EE.  Thanks.
Hi ray, Im not back at work until tomorrow but i will provide you with a stripped down copy and also try saving the XLS and CSV.

10-4.  I'll be here.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It has been decided by management to remove the 0's from the data, This will make data input every month easier and more automated.

I will award points equally thanks again.
javascript:void(0);