Answer the question
In order to leave comments, you need to log in
How to generate output from MySQL when there are more than one queries?
There are several tables in the database. At the moment, I take out one query from 2 tables and display it like this:
while($row = mysql_fetch_array($result))
{
echo "ID: ".$row['id_product']." ";
echo "Имя: ".$row['name']."<br>";
echo "Цена закупочная: ".$row['wholesale_price']."<br>";
echo "Цена продажи: ".$row['price']."<br>";
$list = array ($name.$wholesale_price.';'.$price.';'.$profit);
foreach ($list as $line) {
fputcsv($fp, explode(';', $line));
}
}
Answer the question
In order to leave comments, you need to log in
$queries = [
'cars'=>'SELECT some FROM cars',
'users'=>'SELECT some FROM users'
];
$results = [
'cars'=>[],
'users'=>[],
];
foreach($queries AS $name=>$query) {
//тут выполнение запроса и далее как у Вас:
while($row = mysql_fetch_array($result)) {
$results[$name][] = $row;
}
}
$list = array();
while($row = mysql_fetch_array($result))
{
echo "ID: ".$row['id_product']." ";
echo "Имя: ".$row['name']."<br>";
echo "Цена закупочная: ".$row['wholesale_price']."<br>";
echo "Цена продажи: ".$row['price']."<br>";
$list[] = $name.$wholesale_price.';'.$price.';'.$profit;
}
while (another_query) {
// ...
$list[] = '...';
}
// ...
foreach ($list as $line) {
fputcsv($fp, explode(';', $line));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question