我目前在我的网站上有一个表格,但我需要在表格中类别的文本旁边有一个图标或其他内容,以使值按字母顺序升序,我不知道该怎么做,我已经看过了。
这是我的代码-(是的,我知道它不安全 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>