Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Skip first row in CSV when uploading
    primarykey
    data
    text
    <p>i have this PHP code that uploads a CSV and inserts data into a database, once it has uploaded in the while loop it only selects one row from the CSV:</p> <pre><code>//do upload if (is_uploaded_file($_FILES['dd_submission_form']['tmp_name'])) { echo "&lt;h3&gt;" . "File ". $_FILES['dd_submission_form']['name'] ." uploaded successfully." . "&lt;/h3&gt;"; echo '&lt;h3&gt;Display file contents:&lt;/h3&gt;'; //readfile($_FILES['dd_submission_form']['tmp_name']); } //Import uploaded file to Database $handle = fopen($_FILES['dd_submission_form']['tmp_name'], "r"); fgetcsv($handle, 1000, ","); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $sql="SELECT * from customer where directdebit_reference = '".$data[0]."' "; echo $sql; $rs=mysql_query($sql,$conn) or die(mysql_error()); $customer=mysql_fetch_array($rs); if(mysql_num_rows($rs) &gt; 0) { $sql2="INSERT into dd_submissions (customer_seq, dd_reference, sortcode, account_number, account_name, amount, bacs_code, invoice_no, title, initial, forename, surname, salutation_1, salutation_2, address_1, address_2, area, town, postscode, phone, mobile, email, notes) values ('".$customer["sequence"]."', '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]', '$data[7]', '$data[8]', '$data[9]', '$data[10]', '$data[11]', '$data[12]', '$data[13]', '$data[14]', '$data[15]', '$data[16]', '$data[17]', '$data[18]', '$data[19]', '$data[20]', '$data[21]', '$data[22]')"; $rs2=mysql_query($sql2,$conn) or die(mysql_error()); } } fclose($handle); print "&lt;br&gt;&lt;br&gt;&lt;h3&gt;Successfully Imported Clients&lt;/h3&gt;&lt;br&gt;"; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload