Re: [PHP-DB] Date Formatting in PHP
Hi David, Try this one: ? function formatDate($val) { setlocale (LC_ALL, ''); $arr = explode(-, $val); return strftime (%A %e %B %Y, mktime (0, 0, 0, $arr[1], $arr[2], $arr[0])); } echo formatDate($DatePick); ? Regards, Frank - Original Message - From: David Shugarts [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 11:23 PM Subject: [PHP-DB] Date Formatting in PHP I have a simple need to reformat a variable coming in as $DatePick, brought forward from a MySQL select in the format: 2003-11-18 I need to convert it to the format November 18, 2003 I am trying to avoid having to mess with the MySQL select statement, as the output is being passed through several documents. So I need to do it within PHP. I tried making a conversion like $DayReport = date (F d, Y, $DatePick); But the value of $DayReport is neither correct nor does it change when $DatePick changes. For instance, in this example, the $DatePick value of 2003-11-18 gets converted to December 31, 1969. TIA Dave Shugarts -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Random not working?
Hi All, I'm trying to get a random record each time this script runs; Only it's giving me everytime the first record back.. No random at all.. // generate and execute query $query = SELECT stedenid, naamstad, stadomschrijvk FROM steden ORDER BY RAND() LIMIT 1; $result = mysql_query($query) or die (Error in query: $query. . mysql_error()); $row = mysql_fetch_object($result); echo $row-naamstad; Version info; PHP 4.3.1 Mysql 3.23.54 When i'm trying to excute the SELECT statement in phpmyadmin; i'm only getting the first record back and when i'm taking off the LIMIT 1 it will display all the records in ascending order so also not in random.. Regards, Frank
Re: [PHP-DB] RE: [PHP] Random not working?
Thanks guys for the info; I will speak to my ISP! Have a nice weekend! Regards, Frank - Original Message - From: Rich Gray [EMAIL PROTECTED] To: Frank Keessen [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, March 02, 2003 2:36 AM Subject: [PHP-DB] RE: [PHP] Random not working? Hi All, I'm trying to get a random record each time this script runs; Only it's giving me everytime the first record back.. No random at all.. // generate and execute query $query = SELECT stedenid, naamstad, stadomschrijvk FROM steden ORDER BY RAND() LIMIT 1; $result = mysql_query($query) or die (Error in query: $query. . mysql_error()); $row = mysql_fetch_object($result); echo $row-naamstad; Version info; PHP 4.3.1 Mysql 3.23.54 When i'm trying to excute the SELECT statement in phpmyadmin; i'm only getting the first record back and when i'm taking off the LIMIT 1 it will display all the records in ascending order so also not in random.. Regards, Frank Frank This really belongs on the MySQL list but there was a known issue with RAND() on 3.23.54 - can you upgrade? If your table has an auto_increment ID column then a workaround would be to use rand() in PHP to generate a random ID then use that with a 'where id = '.$id in your query... HTH Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php