I am new to PHP and I've been beating my head again the wall trying to get this to work with no success; I have an SQL query that grabs data from a handful of tables (product name, category, price and product code) then cleans the code up and outputs an RSS feed that works fine.
What I need to do is output the same data as a CSV file; I have searched everywhere and have found some code examples I was able to get to output the entire contents of a single table but none that I could get to work with a query.
Below is a slimmed down version of what I have however the output file has no content and I just don't know what to do from here so if anyone can help I would appreciate it
<?php
include("../inc/db.php");
$product_table = mysql_query("SELECT * FROM ds_products, ds_language_products, ds_product_categories, ds_product_group_pricing
WHERE ds_products.pID = ds_language_products.pID
AND ds_products.pID = ds_product_categories.pID
AND ds_products.pAvail = '$available'
AND ds_product_categories.catID = 114
AND ds_product_group_pricing.pID = ds_language_products.pID
AND ds_product_group_pricing.pgID = 6") or die(mysql_error());
while ($rowr = mysql_fetch_row($product_table)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j]."; ";
}
$csv_output .= "\n";
}
$file = 'export';
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/csv");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>