i have a project looks like this.
i want to view picture then want to write something about this picture. the “gönder” button should effect the right above picture. i want to add these to docYorum in my sql table (i placed it below), then i want to delete if i write my things about this picture.
my codes:
rontgenDoc.php
<?php define('TITLE', 'Requests'); define('PAGE', 'rontgenDoc'); include('includes/header.php'); include('../dbConnection.php'); session_start(); if(isset($_SESSION['is_adminlogin'])){ $aEmail = $_SESSION['aEmail']; } else { echo "<script> location.href='login.php'; </script>"; } ?> <div class="col-sm-4 mb-5"> <!-- Main Content area start Middle --> <?php $sql = "SELECT file_name, hastaAdi, request, requestDetail FROM images"; $result = $conn->query($sql); if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ echo '<div class="card mt-5 mx-5">'; echo '<div class="card-header">'; echo 'Hasta Adı : '. $row['hastaAdi']; echo '</div>'; echo '<div class="card-body">'; echo '<h5 class="card-title">Request Info : ' . $row['request'] . '</h5>'; echo '<p class="card-text">Açıklama: ' . $row['requestDetail'] . '</p>'; echo '<p class="card-text">Röntgen Görseli: <img id="myImg" width="100" height="100" src="../patient/uploads/' . $row['file_name'] . '"></p>'; echo '<div class="float-right">'; echo '<form action="" method="POST"> <input type="hidden" name="id" value='. $row["hastaAdi"] .'><input type="submit" class="btn btn-info mr-3" name="view" value="View"><input type="submit" class="btn btn-secondary" name="close" value="Close"></form>'; echo '</div>' ; echo '</div>' ; echo'</div>'; $num = 12; echo ' <form action="docYorum.php" method="post" enctype="multipart/form-data"> <div class="col-sm-9 col-md-12 mt-5"> <form class="mx-10" action="" method="POST"> <div class="form-group"> <label for="docYorum">Doktor Değerlendirmesi</label> <input type="text" class="form-control" id="docYorum" placeholder="Doctor Yorumu" name="docYorum" value="'.$row['id'].'"> </div> <button type="submit" class="btn btn-info" name="submit">Gönder</button> </form> '; } } else { echo '<div class="alert alert-info mt-5 col-sm-6" role="alert"> <h4 class="alert-heading">Well done!</h4> <p>Aww yeah, you successfully assigned all Requests.</p> <hr> <h5 class="mb-0">No Pending Requests</h5> </div>'; } ?> <?php include('includes/footer.php'); $conn->close(); ?>
docYorum.php:
<?php // Include the database configuration file include('dbConnection.php'); session_start(); $r=session_id(); $statusMsg = ''; $sql = "SELECT file_name FROM images"; $result = $conn->query($sql); $docYorum = $_REQUEST['docYorum']; if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ if(isset($_POST["submit"]) ){ $fileName=$row["file_name"]; $insert = $conn->query("UPDATE images SET docYorum='$docYorum' WHERE id='..'"); } } } // Display status message echo $statusMsg; ?> <script>console.log(<?php echo $sql?>)</script>
Advertisement
Answer
this form in rontgenDoc.php should be like
<form action="docYorum.php" method="post" enctype="multipart/form-data"> <div class="col-sm-9 col-md-12 mt-5"> <div class="form-group"> <label for="docYorum">Doktor Değerlendirmesi</label> <input type="text" name="id" hidden value="'.$row['id'].'"> <input type="text" class="form-control" id="docYorum" placeholder="Doctor Yorumu" name="docYorum" value=""> </div> <button type="submit" class="btn btn-info" name="submit">Gönder</button> </div> </form>
docYorum.php should be like
<?php // Include the database configuration file include('dbConnection.php'); session_start(); $r=session_id(); $statusMsg = ''; if(isset($_POST["submit"]) ){ $id = mysqli_real_escape_string($conn,$_POST['id']); $docYorum = mysqli_real_escape_string($conn,$_POST['docYorum']); $fileName=$row["file_name"]; $insert = $conn->query("UPDATE images SET docYorum='$docYorum' WHERE id='$id';"); } ?>