[ale] [OT] php help
James P. Kinney III
jkinney at localnetsolutions.com
Sat Sep 14 20:38:47 EDT 2002
Hey Drew,
This is where modular programming comes in. By having the <coded stuff>
as a subroutine that you call by passing parameters, you can reuse your
typing more efficiently.
subroutine process_data_not_zero{
my $variable=$0;
while ($variable > 0){
<do stuff>
}
}
subroutine process_data_zero{
<do other stuff>
}
if ($value == 0){process_data_zero($value)}
else {process_data_not_zero($value)}
Fletch can clobber me on any crappy Perl form here, but the basic idea
is simply code reuse.
On Sat, 2002-09-14 at 14:28, ChangingLINKS.com wrote:
> 09-14-02 1247
> Having decided that my Linux admin skillwz are wack, I have been learning to
> program over the last few days. I have gotten all of the code done except
> this problem:
>
> Easy question:
> Currently, I am running a script that starts like this:
>
> $sql = "select * from table where number="1";
> $res = mysql_query($sql);
> if( mysql_num_rows( $res ) > 0 )
> {
> DO THIS PROCESSING;
>
> I know that once the processing is done, there will be no more records where
> number="1" I need to run a different query if $res = 0 So, do I?:
>
> $sql = "select * from table where number="1"
> $res = mysql_query($sql);
> if( mysql_num_rows( $res ) > 0 )
> {
> elseif
> $sql = "select * from links";
> {
> DO THIS PROCESSING;
>
> I just don't want to have to put the else at the bottom and repeat all of the
> code.
>
> --
> Wishing you Happiness, Joy and Laughter,
> Drew Brown
> http://www.ChangingLINKS.com
>
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
> sent to listmaster at ale dot org.
--
James P. Kinney III \Changing the mobile computing world/
President and CEO \ one Linux user /
Local Net Solutions,LLC \ at a time. /
770-493-8244 \.___________________________./
GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7
This is a digitally signed message part
More information about the Ale
mailing list