Showing posts with label php/mysql. Show all posts
Showing posts with label php/mysql. Show all posts

Wednesday, April 8, 2009

Weekly Source Code: PHP Say When Its The Easter Date

Today its Wednesday, 8 April 2009 in a couple of days on Sunday its Easter when we eat a lot of chocolate eggs and spend time with family.

Because Easter is always on a Sunday the date differs each year. By surprise I found that PHP has a easter_date function that returns the easter sunday date given a year or if no year parameter provided for the current year.


Nice if you want to run a special event on your website or offer free choclates on Easter (if you do please let me know!).

Happy Easter!

Saturday, March 28, 2009

Weekly Source Code: No SPAM Email Link In PHP

This is a conversion of my original .Net No SPAM email trick where an email address get retreived via an AJAX call.

This sample uses PHP 5 OOP with the JQuery library written using Netbeans 6.5 IDE.

Get it here.

Thursday, March 5, 2009

Weekly Source Code: PHP - Email Address Images

Sorry ladies & gents that there wasn't a weekly source code last week, work was crazy.

On beds.co.za which is one of the websites I'm working on, you will notice that the email address for an accommodation is actually an image and that there is in the HTML no "mailto:" tag. This is one way to prevent spammers from grabbing your email address from a website by converting the email address to an image and then use my No SPAM email link functionality (that I must still port over from .Net to PHP)

Here's the code that create the image

the email address get stored in $emailAddressEntity, for example "lenniedg@gmail.com"
@imagecreate is the PHP method that create the image.

After this you can refer to the image

Resources:

@imagecreate

Saturday, February 14, 2009

Weekly Source Code: Create A Table With Hyperlinks In PHP

A friend is busy with a website and asked me how to create a table with hyperlinks using PHP/mySQL so in this Weekly Source Code edition I will explain just how.

First you need to connect to the database, for this you use the mysql_connect method, then you run your select SQL query and ouput the result in HTML.

See the sample code.

If you wish to open the result in a popup window then call a Javascript function from the anchor tag's onclick event, in the Javascript function you can open a window with window.open().

Please Note:

- I pass the record id to the updateuser.php page, this is so that the page know which user I wish to update.

- I refer to the record in the row via its field name, you can also refer via its record position in the result for example: $row[1] refer to "Firstname" field.

- This will display all the records in the table, you can add some paging to the table to only display like 10 records at a time.

- For basic PHP you output HTML this way where your PHP and HTML code get mixed, its generally a good idea to use a template framework like Smarty where application code is seperated from the presentation.

References:

PHP mySQL Functions
PHP Manual