just me and php Posted November 6, 2006 Share Posted November 6, 2006 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 RightThanks[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' > <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] Quote Link to comment Share on other sites More sharing options...
Caesar Posted November 6, 2006 Share Posted November 6, 2006 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] Quote Link to comment Share on other sites More sharing options...
just me and php Posted November 6, 2006 Author Share Posted November 6, 2006 Thanks For The ReplyI 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 AMBut 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 AMAnd Inputs Were 2 Seconds Apart It Will Show 2 Hours And 2 Seconds I Dont Want That I Want The 2 Second Apart Time. Quote Link to comment Share on other sites More sharing options...
Caesar Posted November 6, 2006 Share Posted November 6, 2006 That is why I asked what method you're using to input stamps or dates into the database. If you use PHP's time() fuinction, it does not use the user's local time, it uses the server's default time. Quote Link to comment Share on other sites More sharing options...
just me and php Posted November 7, 2006 Author Share Posted November 7, 2006 Ok I Think You Are Asking Me This.This Is The Code That Inserts The Data To Database, Can This Be Modified So When Its Inserting Data It Also Inserts Server Time.I Hope Im Explaining Right.[code] $query = 'INSERT INTO ' . $tablename . ' (' . $fields . ') VALUES (' . $values . ')';[/code] Quote Link to comment Share on other sites More sharing options...
Caesar Posted November 8, 2006 Share Posted November 8, 2006 The values for those variables are set on a conditional basis. In other words, that doesn't tell me what format or code it is using to determine the date. That is the part of the code I would need to look at. ;-) Quote Link to comment Share on other sites More sharing options...
just me and php Posted November 9, 2006 Author Share Posted November 9, 2006 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 IDThanks Again For Trying :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.