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>
First of all, instead of a
forloop, 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.