I have a contact form at my wordpress site, which it's data to mysql and also sends it with mail. I'm currently working on a simple wep app that simply reads the data from the database and prints it. To make it easier to read on mobile, I want that every second row printed from the database would be gray and every second white. I tried this but failed miserably, as you can see from the code. So I want it to look this:
<a href="http://i49.tinypic.com/20fbvdi.png" rel="nofollow">http://i49.tinypic.com/20fbvdi.png</a>
And here's the code:
Please don't get nightmares from the code, it's valid enough for me, and I'm the only one using the web app
<a href="http://i49.tinypic.com/20fbvdi.png" rel="nofollow">http://i49.tinypic.com/20fbvdi.png</a>
And here's the code:
Code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Yhteydenottopyynnöt</title>
<style>
body{width:100%;}
.anotherrow{background-color:#f1f;}
</style>
</head>
<body>
<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("SELECT * FROM wp_contactform");
echo "<table border='1'>
<tr>
<th style='width:10%;'>ID</th>
<th style='width:10%;' class='anotherrow'>Nimi</th>
<th style='width:10%;'>Puhelin</th>
<th style='width:10%;' class='anotherrow'>Sposti</th>
<th style='width:40%;'>Viesti</th>
<th style='width:10%;' class='anotherrow'>P&auml;iv&auml;</th>
<th style='10%;'>IP</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td style='width:10%;'>" . $row['ID'] . "</td>";
echo "<td style='width:10%;' class='anotherrow'>" . $row['Nimi'] . "</td>";
echo "<td style='width:10%;'>" . $row['Puhelin'] . "</td>";
echo "<td style='width:10%;' class='anotherrow'><a href='mailto:" . $row['Email'] . "'>" . $row['Email'] . "</a></td>";
echo "<td style='width:40%;'>" . $row['Viesti'] . "</td>";
echo "<td style='width:10%;' class='anotherrow'>" . $row['Day'] . "</td>";
echo "<td style='width:10%;'>" . $row['IP'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
Please don't get nightmares from the code, it's valid enough for me, and I'm the only one using the web app