Dear Wizard of Menlo Park Jr.;

Similar to what you want but not exactly the same.  Use the bits that you
can use.
I recently took an excel spreadsheet converted it to a tab delimited text
file and then stored the records into a mysql table using the following
code:

Hope this helps,
Hugh

<html>
<body>
<?php
$db="some_database";
$pass="some_password";
$link=mysql_connect("localhost","","$pass");
if (! $link) die("Can't log in at this time");
mysql_select_db($db,$link) or die ("Can't log in at this time");

print "<table align=center cellpadding=7 cellspacing=0 border=1
bgcolor=silver>";

$fp=fopen("excel_file.txt","r") or die ("Couldn't open file");

while (!feof ($fp))
    {
    $record=fgets($fp,100);
    list($last,$first,$title,$rating,$year,$city)= split ("\t", $record, 6);
    print "<tr>
   <td>$first&nbsp;</td>
   <td>$last&nbsp;</td>
   <td>$title&nbsp;</td>
   <td>$rating&nbsp;</td>
   <td>$year&nbsp;</td>
   <td>$city&nbsp;</td>
    </tr>";
    $query="insert into chess_players (first_name, last_name, title, rating,
year, city)
    values ('".addslashes($first)."',
                '".addslashes($last)."',
                '".addslashes($title)."',
                '".addslashes($rating)."',
                '".addslashes($year)."',
                '".addslashes($city)."' )";
    $result=mysql_query($query);
    if (!$result) die ("couldn't update chess_players".mysql_error());
     }
fclose($fp);
mysql_close($link);
print "</table>";
?>
</body>
</html>
----- Original Message -----
From: "Thomas Edison Jr." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 16, 2002 11:16 PM
Subject: [PHP] importing .dat SQL Data into mySQL


> Hi,
>
> I have a .dat file.. with some data like this :
>
> 020000001IN00100213200207120020412200204122002041710002002041720020417
>
> 020000002IN00100213200207220020415200204152002041810002002041820020418
>
> 020000003IN00100213200207320020416200204162002041910002002041920020419
>
>
> This data was exported via SQL Server.. using Oracle.
> I need to use this data in my mySQL Database and work
> on it through PHP.
>
> Can i use phpMyAdmin for this.. or some other method?
>
> Thanks,
> T. Edison Jr.
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to