我整天都在思考和搜索这个问题。我有一个查询:
m_data = std::make_from_tuple<T>(args);
我有一个显示结果的PHP表,上面的查询在phpmyadmin中有效,我已经尝试了几次。但是,在PHP中,它不起作用:如果单击标题,它似乎对结果进行随机排序。日期格式为<tr>
<th>
<a href="?orderBy=name">Asset name</a>
</th>
<th>
<a href="?orderBy=classification">Classification</a>
</th>
<th>
<a href="?orderBy=tag">Tag</a>
</th>
<th>
<a href="?orderBy=department">Department</a>
</th>
<th>
<a href="?orderBy=nextreview">Next review date</a>
</th>
<th>
<a href="?orderBy=responsible">Responsible</a>
</th>
<th>Update</th>
</tr>';
$sql = "SELECT *
FROM `assets`
ORDER BY id";
if (isset($_GET['orderBy'])) {
$orderby = $_GET['orderBy'];
if ($orderby == 'name')
{
$sql = "SELECT * FROM `assets`ORDER BY Asset_name";
}
elseif ($orderby == 'classification')
{
$sql = "SELECT * FROM `assets`ORDER BY Classification";
}
elseif ($orderby == 'tag')
{
$sql = "SELECT * FROM `assets`ORDER BY Tag";
}
elseif($orderby == 'department')
{
$sql = "SELECT * FROM `assets`ORDER BY Department";
}
elseif($orderby == 'Next review date')
{
$sql = "SELECT * FROM `assets` ORDER BY Review_date asc";
}
elseif($orderby == 'responsible')
{
$sql = "SELECT * FROM `assets`ORDER BY Responsible";
}
}
,在phpmyadmin中为日期。我曾尝试创建自定义字段,或只是将sql代码更改为DATE(Review_date),但所有这些都在phpmyadmin中起作用,但在PHP代码中不起作用。
能帮我吗?谢谢!
YYYY-MM-DD
答案 0 :(得分:-2)
为了将数组键称为MySql列名,您需要使用mysql_array_assoc($ result)或mysqli_fetch_array($ result,MYSQLI_ASSOC)。
-编辑- 对不起,我想我不明白您的问题。在这种情况下,我不理解您的问题与代码之间的关系。 “评论”到底是什么?它在什么级别上进行排序?后端?前端?谁是分拣机?