Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to disable edit function when database signed=1 in php

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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>";
    }

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading