:: Alternating Rows :: Script With More Explaining ::

From: Date: Thu, 06 Dec 2001 21:07:13 +0000
Subject: :: Alternating Rows :: Script With More Explaining ::
Groups: php.db 
Request: Send a blank email to php-db+get-14865@lists.php.net to get a copy of this message
The code is supposed to look like this... (Example of code only) ____________________________________ <?php $dbc = mysql_connect("host", "un", "pwd") or die ("Failed Connecting to Database"); @mysql_select_db("dbname") or die ("Failed to Select Databse"); $query = "Select name, surname, email from users"; $result = mysql_query($query) or die ("Failed to Query Database"); if(isset($result)) { $i = 1; while($row = mysql_fetch_array($result)) { $name = $row["name"]; $surname = $row["surname"]; $email = $row["email"]; if(ereg("1$|3$|5$|7$|9$", $i)) { $bg[$i] = "#FFFFFF"; } else { $bg[$i] = "#CCCCCC"; } echo "<TR BGCOLOR=\"".$bg[$i]."\">\n"; echo "<TD>".$name."</TD>\n"; echo "<TD>".$surname."</TD>\n"; echo "<TD>".$email."</TD>\n"; echo "</TR>\n"; $i++; } } mysql_close($dbc); ?> ____________________________ now depending of which colour you want start with, 1 to start with white(#FFFFFF) and 2 to start with grey (#CCCCCC) _____________________________ The code was written off hand, so if you find any errors just let me know. and I'll fix it, but it's a pretty good example of what it should look like. _____________________________ Cheerz Vins +27721807050 vins@webonline.co.za http://www.omfwebdesings.cjb.net/ (Still Under Construction)

« previous php.db (#14865) next »