Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8258797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:40:11+00:00 2026-06-08T02:40:11+00:00

I have a contact form at my wordpress site, which it’s data to mysql

  • 0

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:
http://i49.tinypic.com/20fbvdi.png
And here’s the 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 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:40:14+00:00Added an answer on June 8, 2026 at 2:40 am

    Why not take the more modern approach and use a CSS3 selector?

    tr:nth-child(even) { background: #f1f; }
    

    See here and here for the compatibility statuses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contact form on site which used to work, but since last
I have this contact form which also relates to a few other tables with
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have a contact form which asks users for their name, email address and
I have a contact form which is suppose to go to a thank you
I have a contact form, the values of which I'm passing to a php
Ok I have our contact form fully working, and processing correctly. I have two
I have a contact form on my website, which actually works :D The problem
I have a contact form that connects to my site's back-end, the form submits
I have a contact form in my flash file with name/email/message fields which a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.