Build Table from File PHP Function

This is post is now quite old and the the information it contains may be out of date or innacurate. If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub This little PHP function will allow you to import a csv or tab etc delimited text file into a database table. Handy if you need it :) function build_table_from_file($tablename, $filepath, $delim="\t") { db_query("DROP TABLE IF EXISTS $tablename"); $fp=fopen($filepath, 'r'); $headers=false; while($r=(($delim=='csv')?fgetcsv($fp):fgets($fp))) { if($delim!='csv'){ $r=explode($delim, $r); } if(!$headers) { foreach($r as $h){ $headers[]=trim($h); } $sql = "CREATE TABLE $tablename ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,"; foreach($headers as $h) { $sqls[]=" `" . Read On →

PHP Convert UNICODE to UTF-8

This is post is now quite old and the the information it contains may be out of date or innacurate. If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub If you are struggling with a UNICODE file in your PHP scripts and aren’t ready or able to make the jump to PHP5.3 then this little snippet might help you out: $converted = dirname(__FILE__).'/converted.txt'; $source= dirname(__FILE__).'/source.txt'; shell_exec("iconv -o $conv -f UNICODE -t UTF-8 -V $converted"); Its using the Linux iconv command. Read On →

Magento Wins Best of Open Source Enterprise Software

Magento, the ecommerce package that everyone is talking about at the moment and that Edmonds Commerce have been keeping a close eye on for the past couple of years or so has won the best of open source enterprise software award for the second year running. Run by InfoWorld, the awards highlight the cream of the current open source crop. Unsurprisingly Drupal came out top for content management, it is definitely the CMS that Edmonds Commerce would recommend and Magento took the Ecommerce Crown. Read On →

Magento Connect Search - Easy Solution

The Magento site has recently switched from serving search results internally to using Google to provide the results. Whilst the Google results pages are a lot faster, we now miss the opportunity to search specific areas of the Magento site. In particular, its now a bit of a pain to track down a suitable module in Magento Connect. To make things a bit easier I have knocked together a simple Magento Connect Search tool. Read On →

SSH Public Key Authentication Easy Instructions

This is post is now quite old and the the information it contains may be out of date or innacurate. If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub Just thought I would drop a quick blog and link to this nice succinct guide for setting up SSH to be able to log in via public key. Read On →

Javascript Toggle Checkboxes

This is post is now quite old and the the information it contains may be out of date or innacurate. If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub I seem to use this little snippet loads so I thought I would post it up for safe keeping: Toggling all checkboxes on a page: <script type="text/javascript"> function toggleCheckboxes() { // written by Daniel P 3/21/07 // toggle all checkboxes found on the page var inputlist = document.getElementsByTagName("input"); for (i = 0; i < inputlist.length; i++) { if ( inputlist[i].getAttribute("type") == 'checkbox' ) { // look only at input elements that are checkboxes if (inputlist[i].checked) inputlist[i].checked = false else inputlist[i].checked = true; } } } </script> <button onClick="toggleCheckboxes();">Toggle Enabled Fields</button> I can’t remember where I first found it. Read On →