Hi.............
     Here is the code which wil work for  N no of colums in CSV.
    I hope this will help you..... let me know abt it
   
    $fp = fopen($_FILES['upfile']['tmp_name'], "rt");
$filename = hoge;
while ($data = fgetcsv($fp, 10000)) {
$sql = "INSERT INTO customer_csv (val1,val2,val3..... valn) VALUES 
($data[0],$data[1],$data[2],...... $data[n-1])";
mysql_query($sql);
}
}

   Thank You
   
   
  Regards
  Mohd Asif Ali
  www.phptub.com

tkyosuke_1984 <[EMAIL PROTECTED]> wrote:
  I want to write a script to deal with csv file with more than 3 column, 
which can deal with two column.
How do I use foreach?

The script below is usual script to deal with two column.

$fp = fopen($_FILES['upfile']['tmp_name'], "rt");
$filename = hoge;
while ($data = fgetcsv($fp, 10000)) {
foreach ($data as $value1 => $value2){
$sql = "INSERT INTO customer_csv (name, value1, value2) VALUES ($hoge, 
$value1, $value2)";
mysql_query($sql);
}
}







Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 



  SPONSORED LINKS 
        Php mysql   Job postings 
    
---------------------------------
  YAHOO! GROUPS LINKS 

    
    Visit your group "php-list" on the web.
    
    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
    
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

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



                
---------------------------------
Blab-away for as little as 1ยข/min. Make  PC-to-Phone Calls using Yahoo! 
Messenger with Voice.

[Non-text portions of this message have been removed]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to