I have a View Grid in Php. In this Edit button(like actions edit,delete icons) need to display only for last insertion row. Could you help me how to display like that.Here my code
<?php
$followup_details=mysql_query("select * from tbl_followup where school_id='$id' order by followup_id desc");
if(mysql_num_rows($followup_details))
{
?>
<form name="view-school" method="post" action="">
<table width="100%" border="0" cellspacing="1" cellpadding="1" class="table_txt">
<tr class="table_txt2">
<td width="7%">#</td>
<td width="20%">Minutes Of Meeting</td>
<td width="20%">Details</td>
<td width="13%">Followup Status</td>
<td width="10%">Next Meeting Date</td>
<td width="10%">Actions</td>
</tr>
<?php
$slno=0;
while($followup=mysql_fetch_array($followup_details))
{
$slno++;
?>
<tr <?php if($slno%2==1) echo "class='table_txt3'"; else echo "class='table_txt4'"; ?>><td ><?php echo $slno;?></td>
<td ><?php echo ucwords($followup['mom']);?></td>
<td ><?php echo $followup['details'];?></td>
<td ><?php echo ucwords($followup['followup_status']);?></td>
<td ><?php echo $followup['next_meeting_date'];?></td>
<td>
<a href="#" class="edit-followup" data-reveal-id="editfollowup" data-animation="fade" id="<?php echo $followup['followup_id'];?>"><img src="images/edit_icon.png" alt="editicon" width="20" height="20" border="0" class="marg" /></a>
</td>
<?php }
?>
My Edit Icon only have to display last insertion Row. Please help me. Thanks in advance
maybe something like this:
$numRow= mysql_num_rows($followup_details)
and in your loop:
<td>
<?php if($slno >= $numRow) { ?>
<a href="#" class="edit-followup" data-reveal-id="editfollowup" data-animation="fade" id="<?php echo $followup['followup_id'];?>"><img src="images/edit_icon.png" alt="editicon" width="20" height="20" border="0" class="marg" /></a>
<?php } ?>
</td>
Maybe You can print the edit buttons after you have generated the list, so it is not in the loop, but follows directly afterwards. Or you can check the number of rows before the loop. Then in the loop you put a counter from 1. When the counter is equal to the number of rows, you print the buttons.
First, you can get total no of records before while loop
$total_records = mysql_num_rows($followup_details);
Now check in while loop
if($slno == $total_records -1 )
{
?>
// this is final record
<a href="#" class="edit-followup" data-reveal-id="editfollowup" data-animation="fade" id="<?php echo $followup['followup_id'];?>"><img src="images/edit_icon.png" alt="editicon" width="20" height="20" border="0" class="marg" /></a>
<?php
}else{
echo " ";
}
Just add a check for $slno
is 1. Because you are fetching records on descending order on followup_id
so last inserted record will be on top (the first one).
<td>
<?php
if($slno===1):
?>
<a href="#" class="edit-followup" data-reveal-id="editfollowup" data-animation="fade" id="<?php echo $followup['followup_id'];?>"><img src="images/edit_icon.png" alt="editicon" width="20" height="20" border="0" class="marg" /></a>
<?php
endif;
?>
</td>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.