RSSAll Entries Tagged With: "PHP"

Displaying Mysql Tables in PHP

Once you have a Mysql database setup with a table and some data in that table you are ready to display the data through PHP. This is very easy to do not only efficiently but also with a clean design in mind. So let’s say this is your MySQL table: Categories Id, Title, Description, Timestamp [...]

Javascript & PHP Star Rating Script

Javascript & PHP Star Rating Script

I’ve searched around the interwebs for an ajax star rater and I came across a few different possibilities, all of which looked very good. The top result from google was Nick Stakenburg’s “Starbox” for “ajax star rater”. I also found Masuga Web Design’s Ajax Star Rater and a script from MySandbox to be popular results. [...]

Check if Field Exists in Mysql Table

Sometimes it is useful to know if a field exists in a mysql table before running a query using that field name, especially when the field name is coming from some kind of user input. So to do this we use the function mysql_list_fields to grab the fields out of a table and run through [...]

PHP Prime Number Script

Here is a simple little script that will determine if a number is prime or not. Just submit the function through with the parameter number as the integer you want to determine – is prime or not. Syntax is_prime(number); Here is the function’s definition: function is_prime($num=0) { $num = (int)$num; // Make sure it's an [...]

PHP fopen() Function

The fopen() function will open any valid file or url. If the function fails it will return false along with an error generated. You can hide the error message by adding an “@” in front of the function name. Syntax fopen(filename, mode, include_path, context); Parameters filename (String | Required) This specifies the URL or file [...]

PHP Pagination with Mysql

So you have a Mysql table you want to pull data from, but you don’t want to flood the page with everything in the table right! So you need some pagination to seperate all the content in the table into easy to open pages. So let’s say this is your mysql query: $sql = mysql_query(“SELECT [...]

PHP Date() Function

The date() function converts a given timestamp into a readable date format. Here is the syntax for this function: Syntax date(format,timestamp); Parameters: format This parameter determines the format and how the date will read. For example: “Saturday, Nov. 16th 2009” would be the following code: $timestamp = time(); date(“l, M. jS Y”,$timestamp); timestamp This parameter [...]

PHP Date Formats Reference

Here is a table for formatting the PHP function date() and the letters used to represent different parts of a timestamp. a ‘am’ or ‘pm’ A ‘AM’ or ‘PM’ B Swatch Internet time d day of the month, 2 digits with leading zeros; i.e. ’01′ to ’31′ D day of the week, textual, 3 letters; [...]

PHP Upload and Resize Image

PHP Upload and Resize Image

Many times when you upload a image somewhere you want to resize it to different dimensions based off of a maximum width or height. Here is a simple script that does this for you, using a HTML form and a PHP script. We start with the PHP script that will run if our $_GET['do'] is [...]

PHP Favicon Generator Script

I decided to make a free easy to use favicon generating script that uses PHP. The script has a few features and requirements when uploading your image to be converted to a favicon. First the script checks for a few things such as file type, file size, if the directory is writable, and the specified [...]

The tutorials and scripts found on bgallz.org are for training purposes only, use to your discretion.