mrobinson
02-05-2007, 03:15 PM
Hi there, I have a php page that returns records for a particular mysql query. One of the fields is a timestamp of when the user was added to the database. I'm looking to be put in the right direction for a sample script I can use that for each record will count up how old the record is. I have used this script (http://scripts.hashemian.com/js/countdown.js) however it only seems to work for the last record.
Any help on what I can do to get the count up function working for all records would be greatly appreciated.
The code I have used is as follows:
<?php
//DB Connect
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("userdb") or die(mysql_error());
// Get all the data from the "users" table
$sql="select * from users";
$result = mysql_query($sql) or die(mysql_error());
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Telephone_1</th>
<th>Telephone_2</th>
<th>Telephone_3</th>
<th>More Info</th>
<th>Time Stamp</th>
<th>How Old</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['First_Name'] . "</td>";
echo "<td>" . $row['Last_Name'] . "</td>";
echo "<td>" . $row['Telephone_1'] . "</td>";
echo "<td>" . $row['Telephone_2'] . "</td>";
echo "<td>" . $row['Telephone_3'] . "</td>";
echo "<td>" . $row['More Info'] . "</td>";
echo "<td>" . $row['Time_Stamp'] . "</td>";
echo "<td>" . $row['Time_Stamp'] . "
<script language=\"JavaScript\">
TargetDate = \"12/31/2001 5:00 AM\";
BackColor = \"palegreen\";
ForeColor = \"navy\";
CountActive = true;
CountStepper = 1;
LeadingZero = true;
DisplayFormat = \"%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.\";
FinishMessage = \"It is finally here!\";
</script>
<script language=\"JavaScript\" src=\"http://scripts.hashemian.com/js/countdown.js\"></script>
</td>";
echo "</tr>";
}
echo "</table>";
?>
Thanks in advance!
Any help on what I can do to get the count up function working for all records would be greatly appreciated.
The code I have used is as follows:
<?php
//DB Connect
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("userdb") or die(mysql_error());
// Get all the data from the "users" table
$sql="select * from users";
$result = mysql_query($sql) or die(mysql_error());
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Telephone_1</th>
<th>Telephone_2</th>
<th>Telephone_3</th>
<th>More Info</th>
<th>Time Stamp</th>
<th>How Old</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['First_Name'] . "</td>";
echo "<td>" . $row['Last_Name'] . "</td>";
echo "<td>" . $row['Telephone_1'] . "</td>";
echo "<td>" . $row['Telephone_2'] . "</td>";
echo "<td>" . $row['Telephone_3'] . "</td>";
echo "<td>" . $row['More Info'] . "</td>";
echo "<td>" . $row['Time_Stamp'] . "</td>";
echo "<td>" . $row['Time_Stamp'] . "
<script language=\"JavaScript\">
TargetDate = \"12/31/2001 5:00 AM\";
BackColor = \"palegreen\";
ForeColor = \"navy\";
CountActive = true;
CountStepper = 1;
LeadingZero = true;
DisplayFormat = \"%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.\";
FinishMessage = \"It is finally here!\";
</script>
<script language=\"JavaScript\" src=\"http://scripts.hashemian.com/js/countdown.js\"></script>
</td>";
echo "</tr>";
}
echo "</table>";
?>
Thanks in advance!