Advertisement
Advertisement
| 05.16.2008 at 04:57PM PDT, ID: 23410028 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: |
<?php
if (!$link = mysql_connect('server_name_or_IP', 'username', 'password')) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db('mysql_dbName', $link)) {
echo 'Could not select database';
exit;
}
$sql = 'SELECT * FROM myTable';
$result = mysql_query($sql, $link);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
print "<table align=\"center\" border=\"0\" cellpadding=\"2\" bgcolor=\"#4F5158\">
<tr style=\"color: white;\">
<th>First Name</th>
<th>Last Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Country</th>
<th>Phone</th></tr>";
print "<tr><td></td></tr>";
// Define colors for alternating rows
$color1 = "#fffaf0";
$color2 = "#ffffff";
$row_count = 0;
while ($row = mysql_fetch_row($result))
{
$row_color = ($row_count % 2) ? $color1 : $color2;
print "<tr>";
foreach ($row as $field)
{
print "<td nowrap=\"nowrap\" align=\"center\" bgcolor=\"$row_color\"><font size=\"2\">$field</font></td>";
}
print "</tr>";
$row_count++;
}
print "</table>";
?>
|