Re: mysql select and date functions

From: Date: Wed, 19 Feb 2003 01:16:27 +0000
Subject: Re: mysql select and date functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136096@lists.php.net to get a copy of this message
tnx it worked just like i wanted it to... ----- Original Message ----- From: "Barajas, Arturo" <abarajas@ppg.com> To: "'Sunfire'" <rusty_81@msn.com> Sent: Tuesday, February 18, 2003 7:59 PM Subject: RE: [PHP] mysql select and date functions > Have you tried naming the fields? > > > $query=mysql_query("select dayofmonth(Posted) AS day, > > month(Posted) AS Mo, year(Posted) AS yr, hour(Posted) > > as hr, minute(Posted) as min, Name, Prayer from prayer"); > > and the use > > echo $view->day . "/" . $view->mo . "/" . $view->yr . > "<br>\n"; > > or something similar? > -- > Un gran saludo/Big regards... > Arturo Barajas, IT/Systems PPG MX (SJDR) > (427) 271-9918, x448 > > > -----Original Message----- > > From: Sunfire [mailto:rusty_81@msn.com] > > Sent: Martes, 18 de Febrero de 2003 06:51 p.m. > > To: php-general@lists.php.net > > Subject: [PHP] mysql select and date functions > > > > > > i have a field in a table called Posted and it is a timestamp type > > im using mysql and my page is supposed to take the timestamp > > field and show > > it on the screen in the form of month#/dayofmonth/year > > like 02/18/2003 the problem im having is trying to get it to > > be formatted.. > > i tried mysql functions like dayofmonth(Posted) month(Posted) and > > year(Posted) in the query: > > $query=mysql_query("select dayofmonth(Posted), month(Posted), > > year(Posted), > > hour(Posted), minute(Posted), Name, Prayer from prayer"); > > > > this query works just fine but my question is now in php how > > to display the > > results for dayofmonth(Posted) and so on further code follows: > > while($view=mysql_fetch_array($query)) { > > //display variables from query here... > > > > //get to the date functions: > > //$view[month(Posted)]/... doesnt work > > //php complains about missing ] and this doesnt work > > //either > > while($view=mysql_fetch_object($query)){ > > //show variables here.. > > > > //show date fields in table... > > //$view->dayofmonth(Posted) doesnt work either all i get > > //in display is (Posted) > > ...rest of code here... > > > > ?> > > and its strange because if i try: echo > > $view->dayofmonth(Posted); i get > > parse error call to undefined function dayofmonth() in > > file.php on line > > (line #) > > > > any ideas on how to get this to work? > > > > > > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003

« previous php.general (#136096) next »