标题内带有 url 图像的表格
我有一个 html 中的可排序表,并希望在每个表头中放置一个 add.png ,因此如果用户想要添加另一个 url - 他们只需单击 add.png 并将它们重定向到 addurl.php (如果他们单击外部)仍然会像平常一样对表进行排序)。现在,当我单击 .png 和/或其外部时,它会进行排序。如果这是无法完成的事情,我还考虑过尝试使用 [添加另一个站点] 添加最后一行,但不知道如何将其添加到 $j++ 中,以便它出现在最后一行。
[PHP 片段]
<table class="datatable sortable selectable full">
<thead>
<tr class="theader">
<th width="100%">
<b><li><img src="images/logos/googlebuzz-2-icon.png" height="18" border="0" />Google <a href="addurl.php"><img src="img/icons/add.png" height="18" border="0" align="right"/></a></li></b>
</th>
<th>
<b>Coins</b>
</th>
<th>
<b>CPC</b>
</th>
</tr>
</thead>
<tbody>
<?
$site2 = mysql_query("SELECT * FROM `sites` WHERE `user`='{$data->login}' ORDER BY `cpc` DESC");
for($j=1; $site = mysql_fetch_object($site2); $j++)
{
?>
<tr>
<td>
<? if($site->banned == 1){ ?><font color="red"><? }else{ ?><font color="green"><? } echo($site->title); ?></font><a href="editurl.php?id=<? echo $site->id;?>" class="action-button-small" title="Edit URL"><span class="edit"></span></a>
</td>
<td align="right">
<? if($site->points <= 10){ ?><font color="red"><? }else{ ?><font color="green"><? } echo($site->points); ?></font><a href="addcoins.php?id=<? echo $site->id;?>" class="action-button-small" title="Add Coins"><span class="add"></span></a>
</td>
<td>
<? echo $site->cpc;?>
</td>
</tr>
<?}?>
</tbody>
</table>
I have a sortable table in html and looking to put an add.png inside each table header so if a user wants to add another url - they just click the add.png and redirects them to the addurl.php (if they click outside it will still sort the table just like normal). Right now it sorting when I click on the .png and/or outside it. If this something that can't be done, I've also thought about trying to add a final row with [add another site] but have no idea how to work it into the $j++ so it appears at the final row.
[PHP snippet]
<table class="datatable sortable selectable full">
<thead>
<tr class="theader">
<th width="100%">
<b><li><img src="images/logos/googlebuzz-2-icon.png" height="18" border="0" />Google <a href="addurl.php"><img src="img/icons/add.png" height="18" border="0" align="right"/></a></li></b>
</th>
<th>
<b>Coins</b>
</th>
<th>
<b>CPC</b>
</th>
</tr>
</thead>
<tbody>
<?
$site2 = mysql_query("SELECT * FROM `sites` WHERE `user`='{$data->login}' ORDER BY `cpc` DESC");
for($j=1; $site = mysql_fetch_object($site2); $j++)
{
?>
<tr>
<td>
<? if($site->banned == 1){ ?><font color="red"><? }else{ ?><font color="green"><? } echo($site->title); ?></font><a href="editurl.php?id=<? echo $site->id;?>" class="action-button-small" title="Edit URL"><span class="edit"></span></a>
</td>
<td align="right">
<? if($site->points <= 10){ ?><font color="red"><? }else{ ?><font color="green"><? } echo($site->points); ?></font><a href="addcoins.php?id=<? echo $site->id;?>" class="action-button-small" title="Add Coins"><span class="add"></span></a>
</td>
<td>
<? echo $site->cpc;?>
</td>
</tr>
<?}?>
</tbody>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您应该使用
while
,而不是for
循环:如果您想添加最后一行,只需将其添加到迭代之外、
< 之前;/tbody>
:看来您正在使用 javascript 进行排序。我不知道是否可以更改,以便标题中的添加按钮起作用。
First of all, instead of a
for
loop, you should usewhile
:If you want to add a final row, just add it outside the iteration, before
</tbody>
:It seems you are using a javascript to do the sorting. I don't know if that can be changed so your add button in the header works.
您可以通过检查所有行的实际行来检查它是否是最后一行:
并将其添加到您的 for 循环中:
You can check if it's the final row by checking the actual row against all rows:
And add this in your for loop: