Re: [PHP-DB] Looping advice sought

2002-01-22 Thread Miles Thompson

Good morning George,

As always, it depends on the data.
Knowing how large your queriesare, can you give us a stripped down example 
of two iterations? Not code, just an example of what you're wanting to 
update or insert.

Miles

At 11:24 AM 1/22/2002 +, George Pitcher wrote:
Hi all,

I am about to start on a script page which will loop
thru a MySQL table and update records depending on the
actions of the user.

I propose to loop through, row by row performing a
separate UPDATE statement for each row, unless someone
can advise me of a better way (2d array?).

I am migrating this site from Lasso where I needed to
to do two iterations of the script: the first handles
a single row input and the other handles multiple row
inputs. Do I need to do two with php or will one be
able to handle a count of 1 in a loop just as well as
a multiple count?

MTIA

George


=
George Pitcher

Technical Manager, HERON, Napier University, Edinburgh
0131-455 2435 .. [EMAIL PROTECTED] .. [EMAIL PROTECTED]

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Looping advice sought

2002-01-22 Thread DL Neil

George,

 I am about to start on a script page which will loop
 thru a MySQL table and update records depending on the
 actions of the user.

 I propose to loop through, row by row performing a
 separate UPDATE statement for each row, unless someone
 can advise me of a better way (2d array?).

It would be more efficient to go to the database once, than to make multiple calls.

However you are talking UPDATE (also applies to DELETE) and therefore due care and 
attention must be applied.

UPDATE tblNm SET iq=0 WHERE teamsupported=Rangers;

is likely to affect numerous records (to say nothing of your health!). Whereas if you 
only want to reflect a
change in a single customer's order record

UPDATE tblNm SET source=someuniversitylibrary
  WHERE requestId=1678 and component=part A;

So to achieve a more useful answer can you expand on the description of the 
transaction and/or actions of the
user - or maybe some pseudo-code, please?

=dn



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Looping advice sought

2002-01-22 Thread George Pitcher

Miles,

It's not as bad as some of my queries. Here's my code so far:
= = = = = =
$i=1;
while $i($howmany + 1)
{
$activity=($activity . $i);
$tr_id=($tr_id . $i);

if($activity'' and $activity'Delete'  and  $activity'Submit'){
  if($activity=='Decline')
   $activity='Declined';
  if($activity=='Withdraw')
   $activity='Withdrawn';
  $uquery1 =update Transactions ;
  $uquery1.=SET (PHEIAction, PHEIAccepts) 
  $uquery1.=VALUES 
  $uquery1.=('$activity', '$d1') 
  $uquery1.= WHERE RecID= '$tr_id'
 mysql_query($uquery1);
}elseif($activity=='Submit' or $submit=='Submit Whole Pack'){
  $uquery1 =update Transactions ;
  $uquery1.=SET (PRequestsubmitted, Packorder)
  $uquery1.=VALUES 
  $uquery1.=('$d1', '$Packorder')
  $uquery1.= WHERE RecID= '$tr_id'
 mysql_query($uquery1);
}elseif($activity=='Delete'){
  $uquery1 =update Transactions ;
  $uquery1.=SET CourseID 
  $uquery1.=VALUES 
  $uquery1.=0
  $uquery1.= WHERE RecID= '$tr_id'
 mysql_query($uquery1);
}
= = = = = =
George


- Original Message -
From: Miles Thompson [EMAIL PROTECTED]
To: George Pitcher [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, January 22, 2002 11:49 AM
Subject: Re: [PHP-DB] Looping advice sought


 Good morning George,

 As always, it depends on the data.
 Knowing how large your queriesare, can you give us a stripped down example
 of two iterations? Not code, just an example of what you're wanting to
 update or insert.

 Miles

 At 11:24 AM 1/22/2002 +, George Pitcher wrote:
 Hi all,
 
 I am about to start on a script page which will loop
 thru a MySQL table and update records depending on the
 actions of the user.
 
 I propose to loop through, row by row performing a
 separate UPDATE statement for each row, unless someone
 can advise me of a better way (2d array?).
 
 I am migrating this site from Lasso where I needed to
 to do two iterations of the script: the first handles
 a single row input and the other handles multiple row
 inputs. Do I need to do two with php or will one be
 able to handle a count of 1 in a loop just as well as
 a multiple count?
 
 MTIA
 
 George
 
 
 =
 George Pitcher
 
 Technical Manager, HERON, Napier University, Edinburgh
 0131-455 2435 .. [EMAIL PROTECTED] .. [EMAIL PROTECTED]
 
 __
 Do You Yahoo!?
 Everything you'll ever need on one web page
 from News and Sport to Email and Music Charts
 http://uk.my.yahoo.com
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]