Bruce Gust
asked on
Why am I not getting any data in this CSV file?
Here's my code:
No errors, but no data. What am I doing wrong?
error_reporting(E_ALL);
set_time_limit(600);
include ("carter.inc");
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");
$output="";
$michelle="select * from verizon_test order by id";
$michelle_query=mysqli_query($cxn, $michelle)
or die("Michelle didn't work");
$michelle_columns=mysqli_field_count($cxn);
//gets the field names from your table and sets them up as the first row in your csv file
$heading=mysqli_fetch_fields($michelle_query);
foreach ($heading as $val)
{
$output .='"'.$val->name .'",';
}
$output .="\n";
while($michelle_row=mysqli_fetch_array($michelle_query))
{
for($i=0; $i<$michelle_columns; $i++)
{
$output .='"'.$michelle_row["$i"].'",';
}
$output .="\n";
}
$filename="json.csv";
header('Content-type:appliation/csv');
header('Content-Disposition: attachment; filename='.$filename);
No errors, but no data. What am I doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
BTW: More input would be needed at https://www.experts-exchange.com/questions/28525824/How-can-I-solve-this-problem-with-my-allocated-memory.html