Jump to content

Having Problems displaying data in clean format


spoco

Recommended Posts

Hello. I am trying to get the results of a query to post in a clean format with a header row, etc. I have had no problems getting the data to post, but trying to place it in a formatted table is giving me problems. I am new to PHP/MySQL - any help would be appreciated.

 

<html>
<head>
<title>View Evaluations</title>
<style type="txt/css">

td {
width: 200px;
background-color: #ccc;
}

table {
width: 700px;
border: none;
}

th {
font-weight: bold;
text-align: center;
}

</style>
<style type="text/css">
<!--
.style8 {color: #FFFFFF; font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
.style9 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 24px;
}
-->
</style>

</head>
<body>
<?php require_once("databaseconn.php"); ?>
  
  <?php
mysql_select_db('training', $databaseconn) or die('Could not select database');

// Performing SQL query
$query = 'SELECT * FROM evaluation';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
        echo "\t\t<td>$col_value</td>\n";
    }
    echo "\t</tr>\n";
}
echo "</table>\n";
?>
  </div>
  <p align="center"><span class="style9">Evaluations</span></p>
  <table width="648" height="157" border="0" align="center">
    <tr>
      <td height="37" bgcolor="#0000FF"><div align="center"><span class="style8">1a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">1b</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">1c</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">2a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">2b</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">2c</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">3a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">4a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">5a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">6a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">7a</span></div></td>
      <td bgcolor="#0000FF"><div align="center"><span class="style8">8a</span></div></td>
    </tr>
    <tr>
      <td><div align="left"><?php echo $col_value" ?></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
      <td><div align="left"></div></td>
    </tr>
  </table>
  <p> </p>
</body>
<title>View Evaluations</title></html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.