> I have the following query : > for($i = 0; $i <=$num_results; $i++) > { > $row = mysql_fetch_object($result); > echo "<table width =\"100%\" border =\"0\" cellpadding = \"3\">\n" > ."<tr>\n"
You can save some typing if you just set the bgcolor in the <tr>, instead of each <td>, FYI. Also, align defaults to "left", doesn't it? So you can probably leave that out, also. > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->id</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Nombre</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Apellido</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Direccion</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Ciudad</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Telefono</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Mail</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">$row->Pais</td>\n" > ."<td bgcolor = \"#eeeeee\" align = \"left\">".date("r", > $row->date)."<td>\n" > // My problem is it's getting the wrong date no matter what I do, every line > displays Jan 2038 !!! I think you're confused here. MySQL uses a different style timestamp than a Unix timestamp. Unix timestamps are the number of seconds since Jan 01, 1970. MySQL timestamps are in a YYYYMMDDHHMMSS format. If you've used a TIMESTAMP, DATE, or DATETIME column in MySQL, then you have a MySQL timestamp. The MySQL timestamp is not compatible with the PHP date() function, it is expecting a Unix timestamp. So...the solution is one of two things. You can use an INT column and store the unix timestamp into it. You can create the unix timstamp in PHP with time(), mktime(), or strtotime() (among others), and format it with the date() function. Or, you can continue to use a MySQL type timestamp and use the MySQL function DATE_FORMAT() to format the dates _in your query_. DATE_FORMAT() is the MySQL equivilent of PHP's date() function. Or, as a third option, you can use the MySQL UNIX_TIMESTAMP() function to create a Unix timestamp from the MySQL timestamp and return that to PHP. You can then use that in your date() function. Confusing, eh? If you have any questions, I can explain it further. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php