Hi every1,

I need to update records in a mysql dbase, from a .csv file, everything
works fine, but the index column, $npr_nr from below sometimes has a space
at the end, this causes the dbase index not to match this one, therefore
this record isn't updated.  Do any1 know how I can check for spaces here,
and remove them if present????

Please help, this is quite urgent.
Thanks
Adriaan


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++
+++++++++++++++++++++ checking for new records, not yet in dbase...
++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++*/
$lines = file ('../includes/new1.csv');

foreach ($lines as $line_num => $line) {
list($npr_nr,$npr_exvat,$npr_desc) = explode(",",$line);

$query = "SELECT product_id, product_nr from products";
$currentprs = mysql_query ($query, $db_connection) or die (mysql_error());
while (list ($currentprs_id, $currentprs_nr) = mysql_fetch_row
($currentprs))
{
if ($npr_nr == $currentprs_nr) {
   mysql_query ("DELETE from tmpprods where product_nr =
'$currentprs_nr'",$db_connection) or die (mysql_error());
   } // end if
} // end while
} // end foreach

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++
+++++++++++++++++++++ Finish checking for new records, not yet in dbase...
+++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++*/



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

Reply via email to