can anyone help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »


Did you put quotes around your query

$query = "SELECT .... ";


oops yeh that was it - atleast my data is being displayed again but now I have another problem the date fields appear blank so data isnt being displayed in those fields

the code

$query = "SELECT *, DATE_FORMAT('%d/%m/%y', `dateoflastcontact`)
AS `dateoflastcontact`, DATE_FORMAT('%d/%m/%y', `datecontactagain`)
AS `datecontactagain` FROM `people` ORDER BY `firstname`";


any help
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

:oops: I'm so sorry.. need to switch the order of arguments sent to DATE_FORMAT:

Code: Select all

$query = "SELECT * DATE_FORMAT(`dateoflastcontact`, '%d/%m/%y')
AS `dateoflastcontact`, DATE_FORMAT(`datecontactagain`, '%d/%m/%y')
AS `datecontactagain` FROM `people` ORDER BY `firstname`";
ckuipers
Forum Commoner
Posts: 61
Joined: Mon Mar 24, 2003 6:10 am

Post by ckuipers »

How are you calling the datefields?

dateoflastcontact & datecontactagain?
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

feyd

that doesnt work at all

Code: Select all

$query = "SELECT * DATE_FORMAT(`dateoflastcontact`, '%d/%m/%y') 
AS `dateoflastcontact`, DATE_FORMAT(`datecontactagain`, '%d/%m/%y') 
AS `datecontactagain` FROM `people` ORDER BY `firstname`";

This works but it doesnt display the date for some reason it isnt displaying the dates

Code: Select all

$query = "SELECT *, DATE_FORMAT('%d/%m/%y', `dateoflastcontact`) 
   AS `dateoflastcontact`, DATE_FORMAT('%d/%m/%y', `datecontactagain`) 
   AS `datecontactagain` FROM `people` ORDER BY `firstname`";
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sorry.. forgot to add the comma into the code I copied :oops:

Code: Select all

$query = "SELECT *, DATE_FORMAT(`dateoflastcontact`, '%d/%m/%y')
AS `dateoflastcontact`, DATE_FORMAT(`datecontactagain`, '%d/%m/%y')
AS `datecontactagain` FROM `people` ORDER BY `firstname`";
my brain is off today, I guess :roll:
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

THANK YOU SO MUCH FEYD - problem sorted!! :lol:
Post Reply