gpt4 book ai didi

php - 如何使表上的值上升或下降

转载 作者:太空宇宙 更新时间:2023-11-03 12:27:32 25 4
gpt4 key购买 nike

我目前在我的网站上有一个表格,但我需要在表格中类别的文本旁边有一个图标或其他东西,以使值按字母顺序上升,我不知道如何做到这一点,我已经看过.

enter image description here

这是我的代码-(是的,我知道它不安全 w/mysql_connect)

<?php       
$username="dfgdfg";
$password="dfgdfg";
$database="dfg";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

if (isset($_POST['search']))
{
$columbname = $_POST['selectitem'];
$searchterm = $_POST['searchterm'];
$query="SELECT * FROM transactions WHERE agentclient = '$agentclient' AND $columbname LIKE '%$searchterm%'";
$result = mysql_query ($query) or die(mysql_error());
}
else
{
$query="SELECT * FROM transactions WHERE agentclient = '$agentclient'";
$result = mysql_query ($query) or die(mysql_error());
}

$num=mysql_numrows($result);
mysql_close();
?>

<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr valign="bottom" bgcolor="#000000">
<td width="24"><span class="style1b"><strong>No.</strong></span></td>
<td width="105"><span class="style1b"><strong>Date</strong></span></td>
<!--<td width="57"><span class="style1b"><strong>Agent/client</strong></span></td>-->
<td width="120"><span class="style1b"><strong>Property/Description</strong></span></td>
<td width="199"><span class="style1b"><strong>Transaction type </strong></span></td>
<td width="235"><span class="style1b"><strong>Applicable document </strong></span></td>
<td width="58"><span class="style1b"><strong>Received</strong></span></td>
<td width="58"><span class="style1b"><strong>Paid</strong></span></td>
</tr>

<?php

$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"date");
//$f3=mysql_result($result,$i,"agentclientt");
$f4=mysql_result($result,$i,"propertydescription");
$f5=mysql_result($result,$i,"transactiontype");
$f6=mysql_result($result,$i,"applicabledocument");
$f7=mysql_result($result,$i,"received");
$f8=mysql_result($result,$i,"paid");

?>
<tr valign="top" bgcolor="#FFFFFF">
<td><?php echo $f1; ?></td> <!--id-->
<td><?php echo $f2; ?></td> <!--date-->
<!-- <td><?php //echo $f3; ?></td> --><!--agent/client-->
<td><?php echo $f4; ?></td> <!--desc-->
<td><?php echo $f5; ?></td> <!--type-->
<td><a href="/manage/clientdoc/<?php echo $f6; ?>"><?php echo $f6; ?></a></td> <!--document-->
<td><?php echo $f7; ?></td> <!--recived-->
<td><?php echo $f8; ?></td> <!--paid-->
</tr>

<?php
$i++;
}
?>

</table>

最佳答案

如果您的表格有大量行,请不要使用 javascript 排序。使用服务器端排序。服务器端排序的引用链接 - http://forums.phpfreaks.com/topic/276091-help-with-search-sorting-and-pagination/

关于php - 如何使表上的值上升或下降,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16933263/

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