<table width="400"> <tr> <td><b>name</b></td> <td><b>address</b></td> <td><b>phone</b></td> </tr> <? // connect to database excluded // error checking and result checking excluded
$sql = "select id,name,address,phone from contacts"; $result = mysql_query($sql); while($myrow = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>{$myrow['name']}</td>"; echo "<td>{$myrow['address']}</td>"; echo "<td>{$myrow['phone']}</td>"; echo "</tr>"; } ?> </table> You haven't really said what you want the checkboxes to do, but including them in the while loop is easy, eg: while($myrow = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><input type="checkbox" name="{$myrow['id']}" value="true"></td>"; echo "<td>{$myrow['name']}</td>"; echo "<td>{$myrow['address']}</td>"; echo "<td>{$myrow['phone']}</td>"; echo "</tr>"; } To alternate the row colour between two colours in the loop, you need to: a) initialise a counter $i b) increase it by one every iteration of the loop c) if $i is even, use colour a, else use colour b <table width="400"> <tr> <td> </td> <td><b>name</b></td> <td><b>address</b></td> <td><b>phone</b></td> </tr> <? // connect to database excluded // error checking and result checking excluded $i = 0; $sql = "select id,name,address,phone from contacts"; $result = mysql_query($sql); while($myrow = mysql_fetch_array($result)) { $i++; if(is_int($i / 2)) { $col = "#FFFFFF"; } else { $col = "#CCCCCC"; } echo "<tr bgcolor='{$col}'>"; echo "<td><input type="checkbox" name="{$myrow['id']}" value="true"></td>"; echo "<td>{$myrow['name']}</td>"; echo "<td>{$myrow['address']}</td>"; echo "<td>{$myrow['phone']}</td>"; echo "</tr>"; } ?> </table> Untested code of course :) Season to taste. Justin on 12/01/03 6:57 PM, Karl James ([EMAIL PROTECTED]) wrote: > Hello people > > I was wondering if anyone had a good tutorial or script that I can use > To where I can take a database table and have it print in tables, and > allow me to edit the color > And insert check boxes. > > Thanks > Karl > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php