Dillinger
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by Dillinger
-
-
the DATE_FORMAT () is a MySQL function that the database understands, it's a way of having the database engine format the date for you, instead of doing it in PHP
so to break it down
SELECT column1, column2, column3 etc,
DATE_FORMAT(eventdates.`date`, '%W-%d-%Y') alias
FROM X WHERE Y
alias shows up as a dynamic field in your results set window. you can call it anything you want. this specific code spits out
Monday-26-2004
for the first row.
Scroll down a bit here for the reference
http://dev.mysql.com/doc/mysql/en/date-and...-functions.html
On edit - Of course, I just realized that Monday-26-200x is redundant, so I'll be changing the parameters on that one
-
SELECT buscontacts.fTitle,buscontacts.fForenames,buscontacts.fSurname, candidates.fTitle, candidates.fForenames, candidates.fSurname FROM mydatabase WHERE criteria matched
Alias the field names
SELECT buscontacts.fTitle ftitlefrombus ,buscontacts.fForenames fForenamesfrombus ,buscontacts.fSurname fSurnamefrombus , candidates.fTitle fTitlefromcan
and so on and so forth
-
I am creating a News management system with PHP and MySQl, developing it in Dreamweaver MX2004 and some hand-coding.
I am having a lot of difficulty getting the date to display on a page. I have a MySQl database as follows:
id int(11) NOT NULL auto_increment,
news_headline varchar(255) NOT NULL default '',
news_body text NOT NULL default '',
date_added timestamp(14) default NULL,
I am using:
<?php date_added = date('l M d, Y @ g:i A');
echo ($date_added); ?>
to display the date and time on the page. This worked fine until I realised that all it is doing is displaying the current date and time, not the date that the article was posted in the database. How do I get it to do this?
The way the date function works is that if there's no parameter passed to it, it defaults to now, and you're not passing it any parameters.
In order to get the date out of the date field, try
<?php date_added = date("l M d, Y @ g:i A", $_recordset1['date_added']);
echo ($date_added); ?>
I've been having all sorts of trouble with timestamp to date with this function, today I found a MySQL function to pull the data (date) out of the database just as you want it, skipping having PHP reword it, so in my select statement I have
DATE_FORMAT(eventdates.`date`, '%m-%d-%Y') alias
date is a reserved word in SQL, so use the ` to escape it, alias is just a way to give that record a name that the GUI can handle
include HTML/CSS into PHP
in Editor Help (PhpStorm, VS Code, etc)
Posted
Showing us the code would likely be a good start...