table: |name|US|IN|SA|CHN|AU|EU|.......
|john|0 |12|2 |0 |1 |0 |.......
|andy|20|17|2 |10 |1 |0 |.......
我有一个包含所有国家/地区的 200 列的表。其中包含来自每个国家/地区的点击次数的整数条目。为了在地理图表中显示它们,我想以如下方式解析这些值:
输出:
IN,12
SA,2
AU,1
这样我想排除那些点击次数为0并按用户名john分组的国家
这是我的方法,但它不完整..
$query = "SELECT * FROM `countries`";
$result = mysql_query("SHOW COLUMNS FROM `countries`.`graph_geo_table` WHERE Field NOT IN ('Name')");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
echo $row[Field];
}
}