Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.