George,
Please check out 6.4.5 UPDATE Syntax!
Rather than a complex series of partly nested IF statements, can you rationalise the
structure to a
SWITCH-CASE? - and with neater (than email) formatting improve
readability/comprehension as well?
> $i=1;
> while $i<($howmany + 1)
> {
> $activity=($activity . $i);
> $tr_id=("$tr_id" . $i);
switch ( $activity )
{
case '' : break; // do nothing
case 'Delete' : FnDeleteUpdate( 'Withdrawn' ); break;
case 'Submit' : FnWholePackUpdate( etc); break;
case 'Decline' : fnSingleUpdate( 'Declined' ); break;
case 'Withdraw' : FnSingleUpdate( 'Withdrawn' ); break;
default : DisplayToLog( '***Error' ); exit; //or break
// at the moment this condition is "do nothing"
} // end of switch activity
if ( $submit=='Submit Whole Pack') FnWholePackUpdate( etc);
// note this logic is not quite the same as yours - thus may not be appropriate
> mysql_query($uquery1);
// or it might be tidier to include the MySQL call in the functions
Move:
> $uquery1 ="update Transactions ";
> $uquery1.="SET (PHEIAction, PHEIAccepts) "
> $uquery1.="VALUES "
> $uquery1.="('$activity', '$d1') "
> $uquery1.=" WHERE RecID= '$tr_id'"
into FnSingleUpdate
Move:
> $uquery1 ="update Transactions ";
> $uquery1.="SET (PRequestsubmitted, Packorder)"
> $uquery1.="VALUES "
> $uquery1.="('$d1', '$Packorder')"
> $uquery1.=" WHERE RecID= '$tr_id'"
into FnWholePackUpdate
Move:
> $uquery1 ="update Transactions ";
> $uquery1.="SET CourseID "
> $uquery1.="VALUES "
> $uquery1.="0"
> $uquery1.=" WHERE RecID= '$tr_id'"
into FnDeleteUpdate
I actually prefer to space out the statements in a CASE, but as these are simple the
one-liners may be more
readable. Similarly I tend to space the separate clauses of a SQL query over several
lines, but you may find it
easier to put the SQL statements onto a single line, eg
$uquery1 ="update Transactions SET CourseID = '0' WHERE RecID= '$tr_id' ";
- easier to read/visualise(?), you'll remove the risk of forgetting to put in spaces,
but you'll still have to
watch the convention of which quotation marks to use when and around PHP variables...
NB assuming CourseID is a string (and not an integer - quotes not nec).
NBB are we missing the end of the while loop?
Regards,
=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]