我需要从数据库表中检索一条信息,如何从db中获取mpn号?
我在代码的第 11 行添加了它,但没有显示在结果中?
这是数据库的图像:
<?php
$path = str_replace('/autorun','',str_replace('/controlpanel','',dirname($_SERVER['SCRIPT_FILENAME'])).'/');
$path = '../';
require($path.'start/autorun.php');
$file = $path.'googlebase.txt';
$fh = fopen($file, 'w');
$headerline .= "id\t";
$headings[0] = 'id';
$headings[1] = 'title';
$headings[2] = 'description';
$headings[3] = 'link';
$headings[4] = 'price';
$headings[5] = 'brand';
$headings[6] = 'condition';
$headings[7] = 'image_link';
$headings[8] = 'quantity';
$headings[9] = 'model_number';
$headings[10] = 'availability';
$headings[11] = 'MPN';
fwrite($fh, implode("\t",$headings)."\n");
# Products (+ Reviews)
$products = $db->query('SELECT * FROM products WHERE parent_id = 0 AND enabled = 1 AND hidden = 0 AND id IN (SELECT product_id FROM products_categories) ORDER BY salesrank ASC LIMIT 2000');
$products = $products->getFullArray();
foreach ($products as $product)
{
$productattributes = getProductAttributes($product['id']);
$manufacturer = getManufacturer($product['manufacturer_id']);
$images = getAllProductImages($product['id'], '500', '500');
$mainimage = $images[0]; unset($images[0]);
# Write Line
$row = array();
$row[0] = $product['id'];
$row[1] = $product['title'];
$row[2] = $product['metadescription'];
$row[3] = URL_SITE.$product['pagename'].'/';
$row[4] = $product['price']/100;
$row[5] = $manufacturer['name'];
$row[6] = 'new';
$row[7] = URL_SITE.$mainimage['resized'];
$row[8] = '100';
$row[9] = $productattributes['Model'];
$row[10] = 'in stock';
$row[11] = $productattributes['mpn'];
fwrite($fh, implode("\t",$row)."\n");
}
fclose($fh);
?>