Jump to content

( Solved)help with timestamp from database


just me and php

Recommended Posts

I Would Like To Change How I Post Date/Time, Now I Use A Table From My Database ( $f6 = $row[date];) The Problem Is That Date Is From The Users Computers As They Input Info To Database And I Need Date/Time When Its Posted So When There Is A 2 or More Hour Differents Between Users It Post Date/Time One Right After The Other In Order ( First Come First Served ).
Now I Have Search Here And I See Techs Say NOW() I Dont Under Stand How Or What To Do With That.
Can Someone Explain How To Add A Code Here To Replace The Table ($f6 = $row[date];) With Timestamp Of Database.
Hope I Explain This Right
Thanks

[code]<body bgcolor="#000000" text="#ffffff" link="gold" vlink="gold" alink="gold">
<?
require "config.php";
 
$page_name="1newres.php"; 
if(!isset($start)) {                        
$start = 0;
}

$eu = ($start - 0);
$limit = 200;                                
$this = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;


echo "<TABLE width=95% align=center  cellpadding=0 cellspacing=0> <tr>";
echo "<bgcolor='black' >&nbsp;<font face='arial,verdana,helvetica' color='gold' size='4'><center><b>Home</b></font></center></a><BR>";

echo "<table border='0'><tr>";
$query = "SELECT * FROM table_1   GROUP BY 'id' ORDER BY 'date' DESC limit $eu, $limit ";


$result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error());
$i = 0;
$max_rows = 200;
$num_rows=mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
$fllll= $row[llll];
$f1= $row[id];
$f2 = $row[dis];
$f3 = $row[MS];
$f4 = $row[tk];
$f5 = $row[Username];
$f6 = $row[date];
$f7 = $row[1MS];
$f8= $row[online];
$f9 = $row[MP];
$f10 = $row[hk];
$f11 = $row[dp];
$f12 = $row[date];

if($bgcolor=='#000000'){$bgcolor='#000000';}
else{$bgcolor='#000000';}
if($row[online]=='Y'){$fontcolor ='#00FF00';}
if($row[online]=='N'){$fontcolor ='#FF0000';}
if($row[MP]=='Y'){$fontcolormp ='#00FF00';}
if($row[MP]=='N'){$fontcolormp ='#FF0000';}
if($row[hk]=='Y'){$fontcolorhk ='blue';}
if($row[hk]=='N'){$fontcolorhk ='WHITE';}
if($row[dp]=='N'){$f1='';}
if($row[dp]=='N'){$f2='';}
if($row[dp]=='N'){$f3='';}
if($row[dp]=='N'){$f4='';}
if($row[dp]=='N'){$f5='';}
if($row[dp]=='N'){$f6='';}
if($row[dp]=='N'){$f7='';}
if($row[dp]=='N'){$f8='';}
if($row[dp]=='N'){$f9='';}
if($row[dp]=='N'){$f10='';}
if($row[dp]=='N'){$f11='';}
if($row[dp]=='N'){$f12='';}
if($row[dp]=='N'){$fllll='';}

$i++;
$br++;
if($i == 1){
echo "<td valign='top'>\n";
echo "<table>\n";

}
if($i<=$max_rows){
echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><a href='400newres.php?id=$fllll'><B>$f3</B></font></a></td>\n";

echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><font color='$fontcolor'><B>$f2</B></font></a></td>\n";

echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><a href='members_1.php?id=$f5'><B>$f5</B></font></a></td>\n";

echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><a href='$page_name?id=$f4'><B>$f4</B></font></a></td>\n";

echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='1'><B>$f6</B></font></a></td>\n";

echo "<tr><td>$row[ID]</td></tr>\n";
}
if($i==$max_rows||$br==$num_rows){
echo "</table>\n</td>\n";
$i=0;
}
}
?>
</tr></table>
[/code]
Link to comment
Share on other sites

Where is the code you are using to insert time stamps into the database? And I'm sorry but your english made it dificult for me to really understand all of your post.

Anyway, not sure if this will help but, in my opinion, the easiest way to store dates and then later use them in a conditional statement, would be:

[code]<?php

  $date = time();

  $db->query("INSERT INTO table_1 (date) VALUES ('$date')");

?>[/code]
Link to comment
Share on other sites

Thanks For The Reply
I Already Store The Date And Time In Database From Uses Input.Table Field Is date.
But I Dont Want To Use That Field, I Want To Replace That Field With A TimeStamp.
Heres The Problem.

If I Input Data To Databse It Post The Time I Did it :  11/2/2006 12:10:27 AM
But If Someone Esle Post Data To Database 2 Seconds Later That Is 2 Hours Ahead Of Me (TIME ZONE):11/2/2006 2:10:29 AM

And Inputs Were 2 Seconds Apart It Will Show 2 Hours And 2 Seconds I Dont Want That I Want The 2 Second Apart Time.

Link to comment
Share on other sites

Caesar  Thanks For Trying To Help Me, And Putting Up With My php Stupity.
Any Way I Just Changed This To Make All Post Right After The Other.
[code]$query = "SELECT * FROM table_1  GROUP BY 'id' ORDER BY 'date' DESC limit $eu, $limit ";[/code]
to
[code]$query = "SELECT * FROM table_1  GROUP BY 'id' ORDER BY 'id' DESC limit $eu, $limit ";[/code]
So It Post By The ID
Thanks Again For Trying :)
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.