Change Date from dd/mm/yyyy to yyyy-dd-mm

Conversion
$date_array = explode("/",$date); // split the array
$var_day = $date_array[0]; //day seqment
$var_month = $date_array[1]; //month segment
$var_year = $date_array[2]; //year segment
$new_date_format = "$var_year-$var_day-$var_month"; // join them together

Possibly a more MySQL friendly format in some circumstances.

Change…
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Update Values of Entire Table

This code assumes you are connected to a MySQL database which has a table with Names and Emails. The idea is that it will output a table of every single value from that table, as text inputs. You can then …

Avatar of Chris Coyier
Chris Coyier on

Poll Results: How Do You Email?

The runaway winner was Pure Cloud, with 53% of people that exclusively use an online mail service, through a browser, like GMail or Yahoo or Hotmail or whatever else.
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Send Email

1) HTML Form with Inputs

<form action="" method="post">
  <label for="name">Name:</label>
  <input type="text" name="name" id="name" />

  <label for="Email">Email:</label>
  <input type="text" name="email" id="email" />

  <label for="Message">Message:</label><br />
  <textarea name="message" rows="20" cols="20" id="message"></textarea>

  <input type="submit" name="submit" value="Submit" />
</form>

2) Process with PHP

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Envato Marketplace Redesign

As I’m posting this, the marketplace websites that Envato runs (ThemeForest, GraphicRiver, etc) have been redesigned. It’s a pretty big overhaul… new logos, loads of new features for both buyers and sellers, the iconic “switcher” to change …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Display a Tag Cloud

<?php wp_tag_cloud( array(

    'smallest' => 8,          // font size for the least used tag
    'largest'  => 22,         // font size for the most used tag
    'unit'     => 'px',       // font sizing choice (pt, em, px, etc)
    'number'   => 45,         // 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

“Edit This” Button on Posts and Pages

<?php edit_post_link(__('Edit This')); ?>

Put this in the theme file somewhere near where you output the_content() (likely in the single.php or page.php file) to make a link you can click that takes you into the admin to edit it. This …

Avatar of Chris Coyier
Chris Coyier on

Find the Full Path to a File

<?php
  echo dirname(__FILE__);
?>
  1. Save the file as fullpath.php
  2. Upload to the folder you’d like to know the full path to
  3. Go to http://www.yoursite/lots/of/folders/fullpath.php

You’d might be surprised what shows up. Sometimes you need more than just /lots/of/folders/ as your …

Avatar of Chris Coyier
Chris Coyier on

Password Protect Folder(s)

Put in .htaccess file in the directory you are trying to protect:

AuthType Basic
AuthName "This Area is Password Protected"
AuthUserFile /full/path/to/.htpasswd
Require valid-user

Ideally, the .htpasswd file will be not in a public facing directory. Put this in there:…

Avatar of Chris Coyier
Chris Coyier on