gpt4 book ai didi

php - 显示表中的 MySQL、PHP 过滤结果?

转载 作者:行者123 更新时间:2023-11-29 00:54:51 24 4
gpt4 key购买 nike

我已经搜索过“我认为我应该搜索”的内容 - 但没有真正理解或没有任何进展,请有人能指出我正确的方向吗?

我希望能够使用一列(区域)的 th 过滤结果集,虽然我尝试了 w3cs 教程,但我最终还是对“什么代码”感到困惑goes where”等等,下拉表单看起来很笨重。
欢迎所有建议和帮助。

这是我的示例网站,myTrader单击左侧的“所有贸易区域”链接会显示我所掌握的所有内容,这花了我几天的时间来补习教程并在黑暗中摸索。

到目前为止的 query.php 代码:

    <table id="mainTable">
<tr><td width="300" valign="top"><H1>Welcome to myTrader!</H1>
<span class="mainText">Glass & Paper Recycled Commodities Trading Site</span></td>
<td valign="top" align="right"><img src="images/largeLogo.jpg" width="406" height="113" border="0"></td></tr></table>
<P><span class="paraHeadingOne">All Region Paper Sales</span> </P>
<P>
<table class="dbTable">
<tr>
<tr><th>Commodity</th> <th>Region</th> <th>Member</th> <th>Size</th> <th>Price</th> <th>Date Posted</th>
</tr>
<?php
$link = mysql_connect('localhost', 'palegall', '******');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('palegall_newTrader', $link);
if (!$db_selected) {
die ('cant find newTrader' . mysql_error());
}
$query = mysql_query ("SELECT * FROM `sell` WHERE `commodity`='Paper' ORDER BY `price`") or die( mysql_error() );
$row=mysql_fetch_assoc($query);
do
{
echo'<table class="dbTable">';
echo '<tr><td>'.$row['commodity'].'</td>
<td>'.$row['region'].'</td>
<td>'.$row['member'].'</td>
<td>'.$row['size'].'</td>
<td>'.$row['price'].'</td>
<td>'.$row['posted'].'</td>
</tr>';
}while($row=mysql_fetch_assoc($query));
echo "</table>";
?>
</td></tr></table>
</td></tr></table>
</body></html>

最佳答案

要过滤结果,您需要在查询末尾添加 WHERE columnName = 'desiredValue'。或者,您可以使用 ANDOR 指定多个条件,例如:

 WHERE columnName = 'possibleValue' OR columnName = 'otherPossibleValue'

关于php - 显示表中的 MySQL、PHP 过滤结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6572390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com