PHP, Javascript, CSS & mySQL code snippets

This section of our website contains public source code snippets in a variety of languages which are free to use. Snippets include single lines of code to whole functions and classes.

advertisement

Current page URL
in javascript
 

Get the current title of the page using javascript and store it into a variable

Select code

 

Page title
in javascript
 

Get the current title of the page using javascript and store it into a variable

Select code

 

Close window
in javascript
 

Attempts to close the current window. Good idea for popups

Select code

 

Back button
in javascript
 

Allows you to take a user to the previous page they were on using a button

Select code

 

Convert string to upper/lower case
in javascript
 

Convert a string to all upper or lowercase in javascript

Select code

 

Get length of array
in javascript
 

Get the amount of items, or length, or an array in javascript

Select code

 

Select random record
in mysql
 

This SQL snippet will select a random record from a mysql database

Select code

 

Create random number
in javascript
 

A snippet to create a random number in javascript

Select code

 

Current URL with PHP
in php
 

A samll function to find the current URL of the page

Select code

 

Breakout of frames
in javascript
 

Little bit of javascript which will automatically break out of frames

Select code

 

 
Tips & advice

Need coding help? Tips, tricks or advice? Check out our webmaster forums

advertisement