RE: [PHP] Create table with varying results

From: Date: Thu, 23 May 2002 23:43:50 +0000
Subject: RE: [PHP] Create table with varying results
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99013@lists.php.net to get a copy of this message
My testing was on a Win box with apache/php and browser was ie5.5 - I haven't uploaded the test code to any of my lamp boxes to check it there but don't believe it would matter if I did. > Here is the source for the page: Before testing your code I did make changes, I'll note them as we go... > print "<table border='2' cellspacing='0' > bordercolor='#C0C0C0' width='97%' > id='AutoNumber2' style='border-collapse: collapse' bgcolor='#FFFFFF'>"; You may find compressing a lot of this to a style sheet will aid readability. It is also not necessary to put quotes around only numbers (ie. Border=2 is valid but width="97%" is needed - for 'correct' html anyway - various browser will figure such things out). print "<tr>"; > print "<td width='4%' align='center' [etc] Nothing worth changing in your title row. > $i=0; > $number = 650; > while ($i < $number) : > $name = "Fred Flintstone"; > $email = "My Mail"; > $department = "Department"; OK, my preference is to use: while($i < $number) { } So that's what I changed the test code to. > print "<tr>"; > print "<td width='4%' align='center' > bgcolor='#FFFFFF'><p [etc] Nothing in particular wrong with the display code although using a style sheet would probably help for readability. > $i++; > endwhile; On mine it's a '}' to finish the while loop. I've reloaded it about ten or fifteen times with the exact same result each time. FWIW here's the code that's working here (I stripped out the cell formatting stuff just to make it fit in an email better - but it works here with your formatting in place). <!-- -----8<-----CUT HERE-----8<----- <table border=2 cellspacing=0 bordercolor="#C0C0C0" width="97%" id="AutoNumber2" style="border-collapse: collapse" bgcolor="#FFFFFF"> <tr> <td width="4%" align="center" bgcolor="#FFCC00">&nbsp;</td> <td width="28%" align="center" bgcolor="#FFCC00">Name</td> <td width="13%" align="center" bgcolor="#FFCC00">Phone</td> <td width="29%" align="center" bgcolor="#FFCC00">E-Mail</td> <td width="22%" align="center" bgcolor="#FFCC00">Department</td> <td width="4%" bgcolor="#FFCC00">&nbsp;</td> </tr> <?PHP $i = 0; $number = 650; while ($i < $number) { $name = "Fred Flintstone"; $email = "My Mail"; $department = "Department"; ?> <tr> <td width="4%" align="center" bgcolor="#FFFFFF"><?=$i?></td> <td width="28%" bgcolor="#FFFFFF"><?=$name?></td> <td width="13%" bgcolor="#FFFFFF">255-3698</td> <td width="29%" bgcolor="#FFFFFF"><a href="mailto:fred@fred.fred"><?=$email?></a></td> <td width="22%" bgcolor="#FFFFFF"><?=$department?></td> <td width="4%" bgcolor="#FFFFFF">&nbsp;</td> </tr> <?PHP $i++; } ?> </table> -----8<-----CUT HERE-----8<----- --> CYA, Dave

« previous php.general (#99013) next »