Jump to content

loop problem


smilesmita

Recommended Posts

there is this Db table

 

Tracking number  description

36                  XYZ

46                  abc

98                  lmn

 

i have this loop  in my php file:

$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 96 in the table

98!=46

insert record 96 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?

Link to comment
https://forums.phpfreaks.com/topic/75676-loop-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.