Page 1 of 1

loop problem

Posted: Thu Nov 01, 2007 2:36 pm
by smilesmita
there is this Db table

Tracking number description
36 XYZ
46 abc
98 lmn

i have this loop in my php file:

***** PLEASE USE TAGS WHEN POSTING CODE *****

Code: Select all

$tn=tracking number/numbers received in a file
$rd = $db->Query("SELECT usp_tracking_number,us_id from am_ups_shipment_package_reference");

  for ( $i = 0; $rd && $i < $rd->Row_Count(); $i++ ) {
       $tuple = $rd->Fetch_Row($i);
if ($tuple["Tracking Number"]==$tn){

update the tables with the new data associated with that tracking number
}
else{

insert the new record

}
}
wht is happening:
if the new tracking number provided in the fils is 98 then

98!=36
insert record 98 in the table
98!=46
insert record 98 in the table

98=98

update

wht is wanted is:
98 is compared against 3 and found that its alaredy present and shud just get updated.

Also if a totally new tn is given..for example 33
it doesnt match with any tracking number and gets inserted 4 times.

any idea wht i am missing?

Posted: Thu Nov 01, 2007 4:39 pm
by s.dot

Code: Select all

var_dump($tn);
I don't think it's what you're expecting.