zencart网站获取所有产品ID和所属分类的SQL语句

  1. require("includes/configure.php");

  2. $dbh = @mysql_connect(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD);

  3. if(!$dbh){die("error");}

  4. @mysql_select_db(DB_DATABASE, $dbh);

  5. $getCATIDsql = "SELECT categories_name,products_id FROM categories_description,products WHERE categories_description.categories_id = products.master_categories_id";

  6. $query2 = mysql_query($getCATIDsql,$dbh);

  7. echo '<table border=1><tr><td><strong>产品ID号</strong></td><td><strong>产品所属分类</strong></td></tr>';

  8. while($result = mysql_fetch_array($query2)){

  9. echo '<tr><td>' . $result['products_id'] .'</td><td>'. $result['categories_name'] . '</td></tr>';

  10. }

  11. echo '</table>';


代码用途:获取当前网站所有产品的ID号,以及该ID号码所属分类。


你可能感兴趣的:(zencart)