Web Development Snippets

To move the contents of a directory to a parent directory, first navigate to the child directory and then run the command snippet below.

Setting the display property to inline is an alternative to setting the float property to left.

Using float left is a popular way to make a list horizontal. It tends to have less problems then the alternative, which is using display: inline.

This snippet will add jQuery that is hosted by Google.

This snippet will get the filename from the url. The filename is the last part of the URL from the last trailing slash. For example, if the URL is http://www.example.com/dir/file.html then
file.html is the file name.

It is a good idea to block access to .svn directories if you are using Subversion. Otherwise, anyone can read the files. Add the following snippet to your .htaccess file (in root directory of the website).

Example usage - if a field is a varchar and you need to sort by a number. It will sort it alpabetically, instead of numerically. Type casting will convert it to an altenative data type.

Here is an example of how to select some data from a table on one database and insert into a table of a different database. I am assuming that you are using the same mysql connection.

The MySQL USE command is used to select the appropriate database at the appropriate time. database1 is where the data is being selected from and database2 is where it is inserted to.

 

Modify an existing column to make it auto increment.

Backup a database from cron. Add the following to the cron tab.

Add new user to MySQL database. First, log into the MySQL console, and then run the following command, replacing databasename, username and password.

This is the command to restore a MySQL database.

To restore it on a local computer, follow this process:
1) Open the command line (Windows, Linux or Mac)
2) cd (change directory) to the directory where the mysql.exe is located. This is likely to be in a bin directory. For example, with WAMPserver, mysql.exe is located here:
c:\wamp\bin\mysql\mysql5.0.45\bin

Learn how to write custom Drupal modules

Does Drupal module development make your head explode and drive you crazy?

Why not learn from someone who has paved the way instead?

Sign up to Master Drupal 7 Module Development.

Hello!!

I am Blair Wadman and this is where I write about Drupal, PHP, CSS etc

Stuff

Syndicate

Syndicate content

© Blair Wadman
2005 - 2011