loop problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smilesmita
Forum Commoner
Posts: 30
Joined: Thu May 24, 2007 1:52 pm

loop problem

Post 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?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

var_dump($tn);
I don't think it's what you're expecting.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply