-4

我有这个代码...

<?
    $sql = "SELECT * FROM products where category =". $ID ;
    $result = @mysql_query($sql);
    while ($row=mysql_fetch_array($result))
    {
?>

        <table width="810" valign="center">
            <tr height="100px">
                <td width="150px"><img src="<?php echo($row['imagethumb']) ?>" width="150" height="100" border="0" /></td>

                <td width="200px"><h3><a href='item.php?id=<?php echo($row['id']) ?>'> <?php echo($row['title']) ?></a></h3></td>

                <td width="200px"><h4>$<?php echo($row['price']) ?></h4>  </td>

                <td><h4><a href="<?php echo($row['cartlink']) ?>"><span class="addtocart"></span></a></h4></td>
            </tr>
        </table>

<?
    }
?>

我想按价格对结果进行排序。到目前为止,我还无法让 ORDER BY 'price' ASC 工作。

4

1 回答 1

2

尝试这个:

$sql = "SELECT * FROM products where category ='".$ID."' order by columnname ASC " ;
于 2012-12-29T18:17:06.393 回答