yeahz Posted February 17, 2009 Report Posted February 17, 2009 Kā pareizi jāizvelk no db tas datums un laiks? Es darīju šādi: echo "<table>"; echo "<tr><th>#</th><th>Ieraksts</th><th>Laiks</th></tr>"; $sql = "SELECT * FROM log ORDER BY id desc"; $res = mysql_query($sql); while ($r = mysql_fetch_assoc($res)) { $laiks = date("m.d.y, H:i:s", $r['time']); echo "<tr><td>$r[id]</td><td>$r[name]</td><td>$laiks</td></tr>"; } echo "</table>"; Bet tik reizes cik ir tas while, tik reizes uzmetās errors (tikai pirmais rezultāts strādāja bez erroriem) Warning: date() expects parameter 2 to be long, string given in C:\..\log.php on line 16 Quote
bubu Posted February 17, 2009 Report Posted February 17, 2009 Lieto datuma formatēšanu jau pašā SQL kverijā: http://dev.mysql.com/doc/refman/5.0/en/dat...ion_date-format Quote
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.