Profile
Achievement
brownrl's Recent PHP Snippets
« Prev 1 Next »
This is damn crazy! sQlite does not have all the trig functions need to do distances. So here is how you load that into sQlite on the fly.
0
967
posted 9 years ago by brownrl
This is a quick sublime snippet to quickly setup a DB table for pagination. Ideally from here you will be into a smarty template.
0
732
posted 11 years ago by brownrl
When using PDO with sQlite ->rowCount() doesn't work. the recommendation is to do a pre query to get the number. Thus, I created this snippet to help things along.
0
804
posted 11 years ago by brownrl
This is a custom field handler for a Drupal view. Sometimes you have two or more fields in a content type and you want to do a test on them to see if both are empty or both full or exclusive and return that as a field.
There are probably ways to d...
0
825
posted 11 years ago by brownrl
This is my simple image resizer on the fly thing.
-- WARNING --
Resizing and showing images on the fly could potentially kill your server or make the website slow.
Ideally, this should save the resized image in a cache. However, more often th...
0
1236
posted 11 years ago by brownrl
This is a simple script to go into your downloads directory ( mac ). Move everything to a .YYYY-MM-DD folder. Thus you Downloads directory gets cleaned up and anything that was there has been placed into a hidden folder for finding later.
My Downl...
1
752
posted 11 years ago by brownrl
This is a hook_block_info and hook_block_view template that will allow you to quickly create blocks in a Drupal module. When you use this all you have to do is create a directory "blocks" in the module and then create block.block_name.php in the dire...
0
848
posted 11 years ago by brownrl
This is a skeleton mock up for showing a database table in a basic datagrid with sorting and pagination.
0
1132
posted 13 years ago by brownrl
Simple simple simple function to make a checkbox for a form. Retains checked status.
0
730
posted 13 years ago by brownrl
Some times you need to generate a code for a field in a db and that code can't be repeated either...
Yes, I know that if two people submit their data at almost the exact same time that it could be possible that they have the same code. OMG OMG OMG...
0
769
posted 13 years ago by brownrl
I use this little guy to get the width and height from a filename. Often when I need to show a flash swf file I don't have an easy way to tell the width and the height of the file for display. However is the file name is "some_flash_file 300x250.swf"...
0
1042
posted 13 years ago by brownrl
Here is a little bit of code I use from time to time to make a generic some what safe date selector for forms. I wanted something easy, small, and not relying on images, jquery, libraries, etc... Most importantly I wanted the date that was selected t...
0
736
posted 14 years ago by brownrl
This is one of my favs to use and reuse. Essentially, we make a select box on what is in the table filled values/labels.
Download the ISO countries list to make a country table and Bam! with this function you got a country select box... Also grea...
1
723
posted 15 years ago by brownrl
Quick little function to give you a select box for numbers ranging from min to max. Perfect for birthday date selectors.
0
705
posted 15 years ago by brownrl
Here is a small function that I use to update records in a database.
It coincides with the insertFromPost function that I have posted earlier.
The element names in the form need to have the same name as in the DB and the field names should all...
1
879
posted 15 years ago by brownrl
This is a slightly hard core email check. I work for clients that want real email addresses. They pay quite a bit of money so yes, I am going to give what they want...
3
858
posted 15 years ago by brownrl
Face it!
Whenever you make a website/app you always need to make XLS export for the simple people. I mean heaven to betsy if they have to take a csv file, or use phpMyAdmin.
So
Here are 3 little functions and a sample skeleton that I use fro...
6
1301
posted 15 years ago by brownrl
This is a long over due update to my db insert building function. Please not that the function is the important part the code below is just prove that it works... l:-)
1
690
posted 15 years ago by brownrl
This is a good way to validate form input from PHP, in essence this could be a blue print for your forms.
5
962
posted 15 years ago by brownrl