Follow Me
Subscribes Hell Buddy Solution.

Google+
^
Back To Top

Feel Glad finally done the Meta Tags generator and video :) project
- type: seo html - 30 September 2014 Tue @Hell Buddy

close
Home Message Share Translate

MySql Date_Format() with PHP Array Assoc

10August 2014
Sunday



How to retrieve MySQL DATE_FORMAT() date with using PHP associative array

The another method to display date format string with using 3 following functions;


Read the content or code / instruction -

MySQL AS clause

Use AS clause alias to "mask" the column name becomes a one single name that will make a variable and run PHP statement easier.

  1. MySQL AS clause alias to rename the table column name

  2. SELECT DATE_FORMAT(login_date, '%D %M %Y %r') AS date FROM table_name;

  3. MySQL: try this ~

  4. SELECT DATE_FORMAT(NOW(), '%D %M %Y %r') AS date;

PHP assoc array with if else statement

$result = mysql_query($query);//$query='SELECT ...statement as above'

if(!$result){ .....; exit; } else{....}//not result exit the page

mysql_fetch_assoc()

$row = mysql_fetch_assoc($result); //fetch associative array
mysql_free_result($result); //keep free to continue
$row('login_date'); //retrieve the date


This function will replace by mysqli_fetch_assoc() , it will be removed in the future as PHP 5.5.0.

open the content >>

see the code OR slideshow instruction

Step 1 - Clumsy column name

the column name looks so weird clumsy!

Step 2 - MySQL Date_Format() AS clause

Use AS clause to mask the column name becomes to a one single variable

Step 3 - Output column

the clumsy column name has been changed to easier read.

Step 4 - PHP assoc array

mysql_fetch_assoc() with PHP if else statement

Watch next videos and relative source page(s)

tag MySQL - php html
Programming Web Development Networking FunG project

Topic Discussion:

No Topic Discuss Now...
programming