if I want to disable the edit when database signed=1, how to change it?
$result = mysqli_query($con,"SELECT * FROM `works` WHERE status='1' LIMIT $offset, $total_records_per_page"); while($row = mysqli_fetch_array($result)){ $tunnelfee = get_tunnelfee($con , $row["tunnel_fee"]); $claim = get_claim($con , $row["claim"]); echo "<tbody id=myTable><tr> <td>".$row['work_id']."</td> <td>".date("h:i A", strtotime($row['arrival_time']))."</td> <td>".$row['total_working_hours']."</td> <td>HKD ".$row['fee']."</td> <td>HKD ".$tunnelfee."</td> <td>HKD ".$row['other_fee']."</td> <td>HKD ".$row['total_fee']."</td> <td>".$claim."</td> <td><a href=".$rootDir."invoice/editinvoice.php?id=".$row['id']."><img src=".$rootDir."img/edit.png width=30 height=30></a> <a href=".$rootDir."invoice/view.php?id=".$row['id']."><img src=".$rootDir."img/view.png width=30 height=30></a></td> </tr></tbody>"; } mysqli_close($con);
Thank you.
Advertisement
Answer
You need to add the condition if ($row[‘signed’] !=1){ …. } so that the system can allow editing (or not)
Hence Change
echo "<tbody id=myTable><tr> <td>".$row['work_id']."</td> <td>".date("h:i A", strtotime($row['arrival_time']))."</td> <td>".$row['total_working_hours']."</td> <td>HKD ".$row['fee']."</td> <td>HKD ".$tunnelfee."</td> <td>HKD ".$row['other_fee']."</td> <td>HKD ".$row['total_fee']."</td> <td>".$claim."</td> <td><a href=".$rootDir."invoice/editinvoice.php?id=".$row['id']."><img src=".$rootDir."img/edit.png width=30 height=30></a> <a href=".$rootDir."invoice/view.php?id=".$row['id']."><img src=".$rootDir."img/view.png width=30 height=30></a></td> </tr></tbody>"; }
to
echo "<tbody id=myTable><tr> <td>".$row['work_id']."</td> <td>".date("h:i A", strtotime($row['arrival_time']))."</td> <td>".$row['total_working_hours']."</td> <td>HKD ".$row['fee']."</td> <td>HKD ".$tunnelfee."</td> <td>HKD ".$row['other_fee']."</td> <td>HKD ".$row['total_fee']."</td> <td>".$claim."</td>"; if ($row['signed'] !=1){ echo "<td><a href=".$rootDir."invoice/editinvoice.php?id=".$row['id']."><img src=".$rootDir."img/edit.png width=30 height=30></a> <a href=".$rootDir."invoice/view.php?id=".$row['id']."><img src=".$rootDir."img/view.png width=30 height=30></a></td> "; } else { echo "<td><a href=javascript:alert('Already_Signed');><img src=".$rootDir."img/edit.png width=30 height=30></a> <a href=".$rootDir."invoice/view.php?id=".$row['id']."><img src=".$rootDir."img/view.png width=30 height=30></a></td> "; } echo "</tr></tbody>"; }