Here is the code I have came up for this problem.
$link = mysql_connect($host, $user, $pass) or die("Can not connect to the host." . mysql_error());
mysql_select_db($db) or die("Can not connect to the particular database.");
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ".$table." WHERE forwarded_oce='1'");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j]."; ";
$smallerid = $rowr[$i-1];
$smaller = mysql_query("SELECT budget FROM `db`.`table` WHERE id='$smallerid'");
}
$csv_output .= $smaller;
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
Yani, sorunu farklı bir mysql tablodan ek bilgi ile ekstra sütun eklemek çalıştığınızda boş yazdırır olmasıdır. Ben kodu hatamı bulmak için görünmüyor olabilir, ama belki birisi bilir, ya da en azından doğru yönde bana gelin bu görevleri ile expierence var.
2 farklı MySQL tablodaki verileri birleştirmek ve ikinci tablodan seçilen veriler için tanımlayıcı ilk tablonun son sütununda geliyor - Ne yapmaya çalışıyorum olduğunu.
If you know any framework with could help me solve this issues it would be perfect. I am banging my head against the wall with this problem for 2 days allready and official PHP documentation do not have problems like this in mysql_query section. ..... Thanks!!!!!