Hello, when you request from the database (export price list from Joomla to Excel) records are duplicated
php code is:
header('Content-Type: text/x-csv; charset=utf-8'); header("Content-Disposition: attachment;filename=".date("dmY")."-pricelist.xls"); header("Content-Transfer-Encoding: binary "); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="commis" /> <title>Прайс лист товаров</title> </head> <body>'; echo '<table border="1"><tr><th>№</th><th>Артикул товара</th><th>Наименование</th><th>Цена</th></tr>'; $hostname = 'localhost'; $username = '####'; $password = '####'; $dbName = '###'; mysql_connect($hostname,$username,$password) OR DIE("Не могу создать соединение "); mysql_select_db($dbName) or die(mysql_error()); // Исправтье, если у вас другая кодировка в БД mysql_query('set names utf8'); $data = mysql_query(" SELECT * FROM jos_vm_product LEFT JOIN jos_vm_product_category_xref ON jos_vm_product_category_xref.product_id = jos_vm_product.product_id RIGHT JOIN jos_vm_category ON jos_vm_category.category_id = jos_vm_product_category_xref.category_id RIGHT JOIN jos_vm_product_price ON jos_vm_product_price.product_id = jos_vm_product.product_id ") or die (mysql_error()); while($info = mysql_fetch_array( $data )) { $product_price = substr($info['product_price'], 0, -3); echo "<tr><td>".$info['product_id']."</td><td>".$info['product_sku']."</td><td>".$info['product_name']."</td><td>".$product_price."</td>"; } echo "</table></body></html>"; The result is:
Item Item No. 1 0000-0001 1 0000-0001 1 0000-0001 1 0000-0001 1 0000-0001 2 0000-0002question. Why is duplicated and how to fix it? thanks in advance for your reply
2 0000-0002
2 0000-0002