Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple variable grabbing.

Status
Not open for further replies.

kpdvx

Programmer
Dec 1, 2001
87
US
here is my current code:
$sql_date = '2002-10-10';

$query = "SELECT dayname($sql_date) AS day_name";
$result = mysql_query($query);
@extract(mysql_fetch_array($result));

echo $day_name;

However, this doesnt return anything. Have any ideas as to why?
 
Try it this way:

$query = "SELECT dayname('$sql_date') AS day_name"; ______________________________________________________________________
Perfection in engineering does not happen when there is nothing more to add.
Rather it happens when there is nothing more to take away.
 
Your date should be pulled from a field WITHIN the mysql database.

$query = "SELECT dayname(date_field) AS day_name";
***************************************
Party on, dudes!
[cannon]
 
hmm.. what i am trying to do is take the mysql datetime, 2002-10-10 and format it to say "Tuesday, October 10th, 2002" or whatver the datetime is. I can grab "Octover 10th, 2002" by using this:
// DATETIME STRING FORMAT FUNCTION.
function format_date($sql_date) {
$arr = explode("-", $sql_date);
return date("F j, Y", mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
}

but i want to format it like i mentioned above. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top