I need some help on how to echo out my mysql data into a html table. I'm trying to put in the relevant table tags where necessary but I must be doing it wrong as its not looking how I want it.
Here's what I am getting:
ID Name Number Note Alert
1
2
Nick Nick insurance insurance alert alert
Here is how I want it to look:
ID Name Number Note Alert
1 Nick Insurance Alert
2 Nick Insurance Alert
Here is my code, can someone please show me where I need to put my table tags to get the desired result:
<?php
include 'config.php';
$data = mysql_query("SELECT * FROM supplier_stats") or die(mysql_error());
echo "<table class="table" style="width:900px; font-family: 'Lucida Grande', Tahoma, Verdana, Arial, sans-serif;
font-size:11px; color:#96969;" >";
while ($info = mysql_fetch_array($data))
{
echo "<tr><td><p>" . $info['id'] . "</p></td></tr>";
}
?>
<?php
include 'config.php';
$data = mysql_query("SELECT * FROM supplier_stats") or die(mysql_error());
while ($info = mysql_fetch_array($data))
{
echo "<td><p>" . $info['company_name'] . "</p></td>";
}
?>
<?php
include 'config.php';
$data = mysql_query("SELECT TIMESTAMPDIFF(DAY, insurance_date, NOW()) AS expire_date
FROM supplier_stats") or die(mysql_error()); ?>
<?php
include 'config.php';
$result = mysql_query("SELECT TIMESTAMPDIFF(DAY, insurance_date, NOW()) AS expire_date
FROM supplier_stats") or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$days = $row['expire_date'] - 1;
if ($days > 0)
{
echo "<td><p>Insurance expires in <font color="red">{$row['expire_date']} day(s)!</font></p></td>";
}
else
{
$when = $days * -1;
echo "<td><p>Insurance expires";
if ($when > 1)
{
echo " in {$when} days</p></td>";
}
if ($when >= 8)
{
echo " <div class="green_light"></div>";
}
if ($when <= 7)
{
echo " <div class="red_light"></div>";
}
elseif ($when === 1)
{
echo " tomorrow</p></td>";
}
elseif ($when = 0)
{
echo " today</p></td>";
}
}
}
?>
<?php
include 'config.php';
$result = mysql_query("SELECT TIMESTAMPDIFF(DAY, insurance_date, NOW()) AS expire_date
FROM supplier_stats") or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$days = $row['expire_date'] - 1;
if ($days > 8)
{
echo "a is bigger than b";
}
}
echo "</table>"; //Close the table in HTML
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…