How do I create more than one request for a csv file in one page of code.
What I want to do is query the database then create a csv file with the results, then do another query create a csv file with those results then another query and so on.
I can create a csv file no problem, but don't know how to force the code to automatically move on to the next query.
the code I am using to create the csv file is ;
$result1 = mysql_query("SELECT ConcesRef FROM tblUser WHERE CLogIn = '$username'")
or die(mysql_error());
$ConcesRef = $result1;
if ($result1)
{
header('Content-Type: application/download; name="user_download.csv"');
header('Content-Disposition:attachment; filename="user_download.csv"');
header('Content-Transfer-Encoding: binary');
require_once ('../mysql_connect.php'); //connect to the database
$List = array();
$count = 0;
if (sizeof($List) == 0)
{
//START FILLING IN THE FIELDNAME ON TOP OF EXCEL SHEET.
$fieldSql = "SHOW FIELDS FROM tblUser";
$getFieldInfo = mysql_query($fieldSql);
$i = 0;
while ($row = mysql_fetch_array($getFieldInfo))
{
echo $row['Field'] . ",";
}
echo ("\n");
//START FILLING IN THE ROWS IN EXCEL SHEET.
$sql = "SELECT * FROM tblUser WHERE ConcesRef = $ConcesRef";
$getInfo = mysql_query($sql);
while($row = mysql_fetch_array($getInfo, MYSQL_ASSOC))
{
while (list($key, $value) = each($row))
{
echo ("$value" . ",");
}
echo ("\n");
}
mysql_close();
}
else
{
listErrors();
}
}
else
{
echo "need to pass QS values";
}
I have tried amending the query and then just adding this bwloe the next code, but after creating the first csv file the code just comes to an end - does no more - any ideas?