Hi,
I have got a page with about 50 links to pages like the following:
<?php
/**
* EXAMPLE (iam_dsvdump)
*
* @author Iván Ariel Melgrati <phpclasses@imelgrat.mailshell.com>
* @version 1.0
* @package iam_csvdump
*
* A class form performing a query dump and sending it to the browser or setting it or download.
* Requires PHP v 4.0+ and MySQL 3.23+
*
* Copyright (C) Iván Ariel Melgrati <phpclasses@imelgrat.mailshell.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#####################################################################################################################
# Include the class #
#####################################################################################################################
require_once("../includes/iam_csvdump.php");
#####################################################################################################################
# Set the parameters: SQL Query, hostname, databasename, dbuser and password #
#####################################################################################################################
$dumpfile = new iam_csvdump;
#####################################################################################################################
# Call the CSV Dumping function and THAT'S IT!!!! A file named dump.csv is sent to the user for download #
#####################################################################################################################
# dump($query_string, $filename="dump", $ext="csv", $dbname="mysql", $user="root", $password="", $host="localhost", $list_fields=true )
include("../Connections/functions.php");
$link = @mysql_connect('localhost', '', '');
if (!$link) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('', $link)) {
exit('<p>Unable to locate the skills ' .
'database at this time.</p>');
}
$select = "SELECT skills.skills_id FROM skills WHERE skills.skills_title = 'Agriculture'";
$result = mysql_query($select);
$row = mysql_fetch_row($result);
$id = $row[0];
$select = "SELECT memberskills.memberloginName, skills.skills_title, region.name FROM memberskills LEFT JOIN member ON member.loginName = memberskills.memberloginName LEFT JOIN skills ON skills.skills_id = memberskills.skills_id LEFT JOIN skills_hierarchy ON skills_hierarchy.child = memberskills.skills_id LEFT JOIN memberregion ON memberregion.memberloginName = memberskills.memberloginName LEFT JOIN region ON memberregion.regionid = region.id WHERE skills_hierarchy.parent = $id ORDER BY skills.skills_title";
$result = mysql_query($select);
$numRows = mysql_num_rows($result);
$awcount = 0;
$epcount = 0;
$saalcount = 0;
$samdbcount = 0;
$amlrcount = 0;
$kicount = 0;
$nycount = 0;
$secount = 0;
$othercount = 0;
$file = array();
# DO THE TITLES...
$array = array("Skill", "AW", "EP", "SAAL", "SAMDB", "AMLR", "KI", "N&Y", "SE", "OTHER");
$fileCount = 0;
foreach($array as $value)
{
$file[$fileCount++] = $value;
}
$file[$fileCount++] = GetNewline();
$title = "";
$lastTitle = "";
$started = 0;
while($numRows >= 0)
{
$numRows--;
$array = mysql_fetch_row($result);
if(!$array)
{
$title = "";
}
else
{
$title = $array[1];
}
if($lastTitle != $title)
{
if($started == 1)
{
$array = array(
$lastTitle,
$awcount,
$epcount,
$saalcount,
$samdbcount,
$amlrcount,
$kicount,
$nycount,
$secount,
$othercount
);
$loopcount = 0;
foreach($array as $value)
{
if($value == 0 && $loopcount != 0)
{
$file[$fileCount++] = '0';
}
else
{
$file[$fileCount++] = $value;
}
$loopcount++;
}
$file[$fileCount++] = GetNewline();
}
$started = 1;
$lastTitle = $title;
$awcount = 0;
$epcount = 0;
$saalcount = 0;
$samdbcount = 0;
$amlrcount = 0;
$kicount = 0;
$nycount = 0;
$secount = 0;
$othercount = 0;
}
switch($array[2])
{
case 'Alinytjara Wilurara':
$awcount++;
break;
case 'SA Arid Lands':
$epcount++;
break;
case 'Eyre Peninsula':
$saalcount++;
break;
case 'Adelaide & Mount Lofty Ranges':
$samdbcount++;
break;
case 'Northern & Yorke':
$amlrcount++;
break;
case 'South Australian Murray Darling Basin (SAMDB)':
$kicount++;
break;
case 'Kangaroo Island':
$nycount++;
break;
case 'South East':
$secount++;
break;
default:
$othercount++;
break;
}
}
mysql_close($link);
OutputArrayToCSV("Agriculture.csv", $file);
# $dumpfile->dump("$select", "Agriculture", "csv", "aboriginalnrm", "aboriginalnrm", "nrm123", "localhost" );
?>
Is there a way to have a link or button which will download all of the csv files at once?
Thank you in advance.