RE: [PHP] Re: Code Structure/Errors

From: Date: Sun, 16 Jun 2002 08:02:10 +0000
Subject: RE: [PHP] Re: Code Structure/Errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-102382@lists.php.net to get a copy of this message
Figured it was something simple. Part of the learning process, I suppose. Thanks for the help! Jason Soza -----Original Message----- From: Dan Koken [mailto:dkokenge@netscape.net] Sent: Saturday, June 15, 2002 11:31 PM To: php-general@lists.php.net Subject: [PHP] Re: Code Structure/Errors Can simply set $i before the while. I assume the $last_name is coming from the DB. Not exactly sure what you want, but hope this helps. good luck... Dan. ---------------------- $i = 0; while ($row = mysql_fetch_array($result)) { extract($row); if (($i % 5) == 0) print "<tr>\n"; $i++; @$last_name .= ''; if($last_name <> '') <print stuff here> else <print other stuff> ... if (($i % 5) == 0) print "</tr>\n"; } Jason Soza wrote: > I'm just curious if there's a way to restructure my code so as to avoid > getting "Undefined Variable" errors. I keep getting them and I know they're > nothing to worry about for the most part, I'd like to get rid of them > without turning off error reporting if possible. In the following code, I > get an undefined variable error for $i and for $last_name, is there anything > I can do to actually define them? $last_name is a variable produced by my > MySQL query, $i is just a counter: > > while ($row = mysql_fetch_array($result)) { > extract($row); > $i++; > if($i=="1") { > print "<tr>\n"; > } > > if($last_name) { > <print stuff here> > } else { > <print other stuff> > } > ... > if ($i=="5") { > print "</tr>\n"; > $i=0; > } > } > > Thanks! > > Jason Soza

« previous php.general (#102382) next »