Hey Guys, im fairly new to PhP so i dont really know how to type variables, ive been editing php code, but don't really know how it all works yet. Im stuck with timestamp(database) to php date manipulation if thats the right terms which it probably isnt. Anyway ive found a code to manipulate timestamp with php and i tested it on a blank page and the date displays perfectly for each record from the data base and i can also change the format to D, M, Y and so forth. Im trying to get this exact output in a html table column, every time i try to edit the code and try something new it never seems to work quite right, most of the time i get a 1970 date on all records, or it will pull a date from 1 individual record and display that date for all the records.
I need this
<td class="alt"><?php echo $f5; ?></td>
to pick up this date format with echo, cause it seems as long as echo is in front of date it will work perfectly
echo date("g:i a F j, Y ", strtotime($row["time"]));
Help would be greatly appreciated i just hope i explained it clear enough as i am not well schooled in php thanks
<?php
$i=0;
while ($i < $num) {
$f2=mysql_result($result,$i,"firstname");
$f3=mysql_result($result,$i,"country");
$f4=mysql_result($result,$i,"heal");
mysql_connect("localhost", "root", "pass") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());
$result1 = mysql_query("SELECT timestamp FROM light;");
while ( $row = mysql_fetch_array($result1) ) {
echo date("g:i a F j, Y ", strtotime($row["timestamp"]));
}
?>
<tr>
<td class="alt"><?php echo $f2; ?></td>
<td class="alt"><?php echo $f3; ?></td>
<td class="alt"><?php echo $f4; ?></td>
<td class="alt"><?php echo $f5; ?></td>
</tr>
<?php
$i++;
}
?>