News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPMaster.com:
5 Inspiring (and Useful) PHP Snippets
July 02, 2012 @ 10:58:45

On PHPMaster.com there's a new tutorial that shares some useful PHP snippets that you could use in your development.

"X PHP Snippets" type articles abound on the Internet, so why write another one? Well, let's face itů the PHP snippets in them are generally lame. Snippets that generating a random string or return $_SERVER["REMOTE_ADDR"] for the IP Address of a client really aren't that interesting and are of modest usefulness. Instead, here's five snippets that you'll no doubt find interesting and useful, presented along with the problems that inspired them. I hope the creativity in many of them inspire you to write better and more creative code in your own day-to-day endeavors.

Their "five tips" are about:

  • Generating CSV files from an array of data
  • Autoloading classes (in a PSR-0 way)
  • Parsing data with the unpack function
  • Templating in HTML (creating a "View" object)
  • Using file_get_contents as a cURL Alternative
0 comments voice your opinion now!
snippets csv autoload unpack template filegetcontents


Code2Learn.com:
Generating CSV file using CodeIgniter Framework
April 19, 2012 @ 11:45:52

The Code2Learn site has posted another in their CodeIgniter "series" about producing various kinds of output from an application based on this framework. In this new article Farhan Khwaja shows how to output a CSV-formatted file.

I have already written posts on how to generate pdf files using CodeIgniter Framework and also on how to generate tabulated pdf file using CodeIgniter Framework. This post will help you to generate a CSV file using CodeIgniter. The data for the CSV File will be taken from the MySQL Database and will be put into the CSV File.

He includes the source for a basic "Generate" controller class that uses a custom "CSV_Helper" to do the work. It has two methods - one to transform array data and another to take the database result object and extract each record.

0 comments voice your opinion now!
generate csv file codeigniter framework tutorial output helper


Lorna Mitchell's Blog:
Github to Jira Bug Migration Script
March 09, 2011 @ 10:18:18

As part of a migration the Joind.in project made to track their bugs on a hosted Jira instance instead of the Issue Tracker on Github, Lorna Mitchell, one of the leads on the project has written up an import script she used to move current issues. The code is in her latest post.

I migrated only our open issues, and comments (and the comments ended up a bit weirdly formatted on the other end but this was the best they could do). It was nothing pretty or clever but in case it's useful to someone else.

The script connects to the github API and pulls down the information for the open issues including their titles, user and body of the issue. This is then used to make another connection for each to fetch their comments. The whole thing is dumped out to a CSV file that can be easily imported by the Jira team.

0 comments voice your opinion now!
github jira import issue list bug migrate csv api


Phil Sturgeon's Blog:
PHP Format abstraction with a simple class
February 14, 2011 @ 12:15:13

Phil Sturgeon has posted about a utility he's released that can help convert data from one state to another such as arrays to JSON and XML to CSV - php-format.

Convert between Array, Object, JSON, XML, CSV and Serialized data and back again easily. I'll add a few more types like YAML when I can be arsed to work out PECL for MAMP.

There's a code snippet in his post showing the conversion of an array to JSON then to XML then back to an array. The code is pretty simple to follow with "to" and "from" methods for each format making it simple to extend for your own uses.

0 comments voice your opinion now!
convert data json xml csv serialize


DevShed:
Building an IP-to-Country Mapping Application with PHP
February 04, 2009 @ 08:47:30

DevShed has launched a new four-article series today looking at resolving a user's IP to their country via the database provided here.

If you have content in several different languages, your visitors probably speak several different languages as well. Wouldn't it be nice to serve them content from your site in their native language, based on the country from which they hail? You can, even if you're a small company, with an application that tells you a visitor's country based on their IP address. This four-part article series will show you how to build the application and incorporate it into your web site.

They just get things set up in this first part of the series - grabbing the CSV file from the site, creating the MySQL table to import it into and running a script to parse the CSV and push its data into the table.

0 comments voice your opinion now!
tutorial ip country mapping csv database mysql


TotalPHP.com:
Creating a text or csv file of information from your database
December 10, 2008 @ 08:47:44

On the TotalPHP site there's a new tutorial showing how to pull data from your database and export it as a CSV file that tools like Excel can read in and use.

There are some occasions where you would want to export your site's information in CSV or similar text format. You might want to do this so you can view reports in a spreadsheet, or you might want an export of your product information to upload to a service like Google Products. Either way the method and end result are essentially the same.

The tutorial shows how to grab the information (via the mysqli functionality in PHP5) and formatting each row with the correct values in a certain order. Finally, the entire contents are echoed back out with the correct header() to force a download on the user's browser.

0 comments voice your opinion now!
csv tutorial mysqli database export txt format


Kevin Waterson's Blog:
Introduction to PHP and MySQL How they work together.
September 12, 2008 @ 10:08:59

Kevin Waterson has posted a new tutorial (a very comprehensive one) seeking to make introductions between a developer new to PHP and the MySQL abilities the language has.

This tutorial is aimed at those new to PHP and MySQL. The object of this tutorials is to show by way of example how to use php to CREATE a database, how to CREATE a table, how to INSERT data into a database, and how to SELECT that data and display it on a web page.

The tutorial doesn't get into working with forms and the data submitted in them, but it does give a great overview of basic SQL commands, pushing data into tables and some other simple functions (loading a CSV file, preventing SQL injection and getting the last inserted ID).

0 comments voice your opinion now!
tutorial introduction mysql comprehensive csv lastid injection sql


The Bakery:
Five New Articles, Tutorials and Helpers
September 11, 2007 @ 09:29:00

The Bakery has five new items they've recently posted - a few new articles, helper information and tutorials. Here's the list:

  • CSV Helper - I was recently outputting some comma-delimited data and thought I would benefit from a simple csv helper
  • p28n, the top to bottom persistent internationalization tutorial - For some developers, allowing a website to support multiple languages is essential. Luckily cakePHP 1.2 has the foundations available to make this possible.
  • Tracking navigation history of a user - Many times it can be very useful to track the navigation history of a user. [...] With this HistoryComponent, it's extremely easy to handle such actions.
  • Habtm hacks to menage columns in both models - I had a habtm relationship between two models and when i did a "findall" in a model i couldn't filter the rows with a clause from the the other model.
  • SecureGet Component - I am not pretending this can replace ACL or more complex implementation, it's just a small component, inspired a bit from the Security component.

If you're a CakePHP developer, you'd do well to check out The Bakery for these and more great Cake-related articles, tutorials and information.

1 comment voice your opinion now!
csv internationalization navigation habtm secureget bakery csv internationalization navigation habtm secureget bakery


Brent Meshier's Blog:
Blocking visitors by country using PHP & MySQL
April 23, 2007 @ 16:38:00

In a quick new post from Brent Meshier today, he shows us how, with the help of a database CVS file, to block visitors to your site from certain locales.

A client asked me last night if it was possible to block certain countries from accessing his website. He's concerned about the "axis of evil" and their comrades downloading his software. The task is easily accomplished, although it's like using a sledge hammer to tap in a finishing nail. He didn't seem too concerned that we could accidentally block Uzbekistan in the process. Unfortunately his entire site uses plain .html files, no dynamic scripting. This led me to using a slightly creative solution with .htaccess.

Broken up into five simple steps, he makes a light function to drop into an output buffering function to tell it to either show the normal content or return a 401 Unauthorized header to the visitor.

0 comments voice your opinion now!
mysql block visitor country download csv database htaccess mysql block visitor country download csv database htaccess


InformBank.com:
How to create Microsoft Office documents on the fly using PHP
August 07, 2006 @ 11:57:37

In this new tutorial from InformBank posted today, they show how to use PHP (and a few handy tricks) to create Microsoft Office documents on the fly.

Sometimes you have to generate some MS Office document for the users of your website using dynamic data. For example, few days ago, I had to generate some Excel reports using data from some tables in MySQL. I knew about the COM but it has a lot of disadvantages, including Windows-only platform and not very high speed. CSV is much easier and faster but you can't format the cells to make them better-looking. The method I've never thought about before was using HTML.

So here came the inspiration and after some research and experiments I wrote this tutorial for all of you who are looking how to create Office documents on the fly using PHP. Of course, I included the COM methods and some methods to create other MS Office documents like DOC and PPT, to make this tutorial as full and as useful as possible.

The tutorial starts with the creation of documents (Word, Excel, Powerpoint) with the COM functionality (the standby method PHP has had for a while). Of course, it also requires the script to be running on Windows to work. So, what's the other option? As he goes on to explain, it's something as simple as HTML.

He includes two examples of alternate mathods, showing hhow to use HTML or a CSV file to create a custom Excel document. He also throws in some code to help you stream out the resulting document as a zip file to the browser.

0 comments voice your opinion now!
microsoft document onthefly com extension html csv file microsoft document onthefly com extension html csv file



Community Events





Don't see your event here?
Let us know!


unittest laravel list language wordpress introduction library code configure bugfix symfony developer series application community api podcast interview release install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework