<div id="hd" role="banner"> <h1>CSV to web service</h1> <ul><li><a href="index.php">Index</a></li><li><a href="http://github.com/codepo8/csv-to-webservice">Download on GitHub</a></li></ul> </div> <div id="bd" role="main"> <p>This is a demo page for the <code>csvtoservice.php</code> script that uses <a href="http://developer.yahoo.com/yql">YQL</a> to convert CSV resources to web interfaces.</p> <h2>What you can do with this</h2> <p>This script allows you to get any CSV file from the internet and turn it into a web interface that empowers users to search and filter the data.</p> <p>The following is an example, try it out. Simply hit the search button and see the results.</p> <div id="example"> <h3>Olympic Winter Medals Albertville 1992</h3> <p>Simply enter your search criteria in the appropriate field and submit the form.</p> <?php include 'csvtoservice.php'; $content = csvtoservice('http://winterolympicsmedals.com/medals.csv', array('filter' => array('eventgender', 'city'), 'rename' => array('noc' => 'country'), 'preset' => array('year' => '1992'), 'prefill' => array('discipline' => 'Alpine Skiing', 'medal' => 'Gold'), 'uppercase' => true)); // if it could be loaded and parsed... if ($content) { // show the form echo '<h4>Filters</h4>'; echo $content['form']; // show the table if ($content['table']) { echo '<h4>Results</h4>'; echo $content['table']; } } ?> </div> <h2>The code</h2> <p>The above search form and table result is powered by a simple dataset: <a href="http://winterolympicsmedals.com/medals.csv">http://winterolympicsmedals.com/medals.csv</a>. All you need to convert it to what you see above is the following code in your PHP documents:</p>
<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Simplest example of csvtoservice.php</title> <link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css"> <link rel="stylesheet" href="styles.css" type="text/css"> </head> <body> <div id="doc" class="yui-t7"> <div id="hd" role="banner"> <h1>Simplest example of csvtoservice.php</h1> <ul><li><a href="index.php">Index</a></li><li><a href="http://github.com/codepo8/csv-to-webservice">Download on GitHub</a></li></ul> </div> <div id="bd" role="main"> <?php include 'csvtoservice.php'; $content = csvtoservice('http://winterolympicsmedals.com/medals.csv'); // if it could be loaded and parsed... if ($content) { // show the form echo '<h2>Filters</h2>'; if ($content['form']) { echo $content['form']; } // show the table if ($content['table']) { echo '<h2>Results</h2>'; echo $content['table']; } } ?> </div>