Jump to content

Ronel

Members
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Ronel

  • Rank
    Member
  1. Ronel

    PHP update

    Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in /opt/lampp/htdocs/new1/ronel_detail.php on line 15 Fatal error: Uncaught mysqli_sql_exception: No data supplied for parameters in prepared statement in /opt/lampp/htdocs/new1/ronel_detail.php:16 Stack trace: #0 /opt/lampp/htdocs/new1/ronel_detail.php(16): mysqli_stmt->execute() #1 {main} thrown in /opt/lampp/htdocs/new1/ronel_detail.php on line 16 This is the error it gave me!
  2. Ronel

    PHP update

    <?php mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect("localhost","root", "","update"); // // PROCESS POSTED DATA // if ($_SERVER['REQUEST_METHOD']=='POST') { $stmt = $conn->prepare("UPDATE ronel SET status = ?, comment = ?, department = ? WHERE id = ? "); $stmt->bind_param('ssi', $_POST['status'], $_POST['comment'], $_POST['department'], $_POST['id']); $stmt->execute(); header("Location: ronel_dashboard.php"); exit; } if (!isset($_GET['id']) || trim($_GET['id'])=='') { header("Location: "); exit; } $res = $conn->prepare("SELECT id , location , status , comment , department FROM ronel WHERE id = ? "); $res->bind_param('i', $_GET['id']); $res->execute(); $res->bind_result($id, $location, $status, $comment, $department); $res->fetch(); $res->close(); // // status-dependent processing // $buttons = "<div class='data'> <button name='status' class='w3-button w3-khaki' value='$status'>Update</button> </div> "; ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Details</title> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style type='text/css'> body { font-family: calibri, sans; font-size: 12pt; } label { display: inline-block; width: 150px; background-color:#E4EBC5; color:orangered; padding: 8px; font-weight: 600; margin-right:30px; vertical-align: top;} .data { display: inline-block; width: 500px; padding: 8px; vertical-align: top;} /*.comment { display: inline-block; width: 450px; vertical-align: top;} */ </style> </head> <body> <header class="w3-display-container w3-orange w3-padding" style='height:90px;'> <div class="w3-left"> <h2>Details</h2> </div> <div class="w3-right w3-margin"> <a href='ronel_dashboard.php' class='w3-khaki w3-button'>Dashboard</a> </div> </header> <div class='w3-container'> <form method='POST'> <input type='hidden' name='id' value='<?=$id?>'> <div class="w3-card w3-padding" style='max-width: 750px; margin: 30px auto;'> <div> <label>ID</label> <div class="data"><?=$_GET['id']?></div> </div> <div> <label>Location</label> <div class="data"><?=$location?></div> </div> <div> <label>Status</label> <div><?=$status?></div> </div> <div> <label>Comments</label> <div class="data"><textarea name='comment' class='w3-input w3-border' rows='5'><?=$comment?></textarea></div> </div> <div><label for="cars">Select Department:</label> <div class="data"> <select id="department"> <option value="volvo">MMD</option> <option value="saab">O&M</option> <option value="opel">Civil</option> <option value="audi">C&M</option> </select> </div> </div> </div> <div class='w3-content w3-center w3-padding'> <?=$buttons?> </div> </form> </div> </body> </html> Dear Sir/Madame Can someone help me with this piece of code? I have tried updating a comment section with approve and reject status button here and Sir Barand has helped me a lot with the project code which he provided me!! Now after the approval/reject part done what i am trying to do is update a department section with the comment section as well and instead of approve/reject button i want to update only with a different page.
  3. Sir it says= <?php $conn = mysqli_connect("localhost","root", "","update"); // // Check if data was posted for processing // if ($_SERVER['REQUEST_METHOD']=='POST') { $stmt = $conn->prepare("UPDATE ronel SET status = ? WHERE id = ? "); $stmt->bind_param('si', $_POST['status'], $_POST['id']); $stmt->execute(); header("Location: #"); // reload the page exit; } $pendingRecs = ''; $res = $conn->query("SELECT id , details , location , status , comment FROM ronel WHERE status = 'Pending' ORDER BY date, time "); if ($row = $res->fetch_assoc()) { do { $pendingRecs .= " <form method='post'> <input type='hidden' name='id' value='{$row['id']}'> <tr> <td>{$row['id']}</td> <td>{$row['details']}</td> <td>{$row['location']}</td> <td>{$row['status']}</td> <td>{$row['comment']}</td> <td><button name='status' value='Approved' class='w3-button w3-green'>Approve</button></td> <td><button name='status' value='Rejected' class='w3-button w3-red'>Reject</button></td> <textarea name='comment' cols='50' rows='5'><?=$comment?></textarea> </tr> </form> "; } while ($row = $res->fetch_assoc()); } else { $pendingRecs = "<tr><td colspan='7'>No Pending records</td></tr>" ; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Dashboard</title> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style type='text/css'> body { font-family: calibri, sans; font-size: 12pt; } </style> </head> <body> <header class="w3-container w3-orange w3-padding w3-center"> <h2>Dashboard</h2> </header> <div class="w3-content w3-padding"> <table class="w3-table w3-bordered"> <tr style="background-color:#E4EBC5; color:orangered;"> <th>ID</th> <th>Details</th> <th>Location</th> <th>Status</th> <th>Comment</th> <th colspan="2">Action</th> </tr> <?=$pendingRecs?> </table> </div> </body> </html> Notice: Undefined variable: comment in /opt/lampp/htdocs/new1/view.php on line 44
  4. Thanks a lot. Sir it is working now but one more trouble sir and that is i need to put a comment text box with the approve and reject button!!
  5. Sir lets say i don't want to show the details,date and time, in the dashboard only status,id,location and comment with a click button on its side to view the full details. Now, when i click the full details button it href me to another page and shows me the full details? How do i that here with the same code or do i need to change anything in order to achieve it??
  6. Sir what if i want to display the data from the database with a link and when i click on the link shows the whole database on the other page? The whole status comment and details all? can it be possible? please help me out with this ! <body> <h2 style="text-align:center; color:orangered;"> DASHBOARD </h2> <table> <h3> <tr style="background-color:#E4EBC5; color:orangered;"> <th>ID</th> <th>Details</th> <th>Location</th> <th>Status</th> <th>Comment</th> </tr> </h3> </table> <?Php //////////////////////////////////////////// require "dbconfig.php"; // MySQL connection string $count="SELECT id,details,location,status,comment FROM ronel"; if($stmt = $connection->query($count)){ while ($nt = $stmt->fetch_assoc()) { echo " <body> <table> <tr> <td><a href=view.php?id=$nt[id]>$nt[id]/$nt[department]</a></td> <td>$nt[id]</td> <td>$nt[details]</td> <td>$nt[location]</td> <td>$nt[status]</td> <td>$nt[comment]</td> </tr> </table> </body> "; } }else{ echo $connection->error; } ?>
  7. great help from you thank you a ton sir you made my day awesome i have been trying these for days!! i cannot thank you enough .
  8. Sir this is my dbconfig.php <?php $connection = mysqli_connect("localhost","root", "","update"); ?>
  9. Sir this has come!! I cannot seem to fine the solution 😕 <?php require "dbconfig.php"; // // Check if data was posted for processing // if ($_SERVER['REQUEST_METHOD']=='POST') { $stmt = $conn->prepare("UPDATE ronel SET status = ? WHERE id = ? "); $stmt->bind_param('si', $_POST['status'], $_POST['id']); $stmt->execute(); header("Location: #"); // reload the page exit; } $pendingRecs = ''; $res = $conn->query("SELECT id , details , location , status , comment FROM ronel WHERE status = 'Pending' ORDER BY date, time "); if ($row = $res->fetch_assoc()) { do { $pendingRecs .= " <form method='post'> <input type='hidden' name='id' value='{$row['id']}'> <tr> <td>{$row['id']}</td> <td>{$row['details']}</td> <td>{$row['location']}</td> <td>{$row['status']}</td> <td>{$row['comment']}</td> <td><button name='status' value='Approved' class='w3-button w3-green'>Approve</button></td> <td><button name='status' value='Rejected' class='w3-button w3-red'>Reject</button></td> </tr> </form> "; } while ($row = $res->fetch_assoc()); } else { $pendingRecs = "<tr><td colspan='7'>No Pending records</td></tr>" ; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Dashboard</title> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style type='text/css'> body { font-family: calibri, sans; font-size: 12pt; } </style> </head> <body> <header class="w3-container w3-orange w3-padding w3-center"> <h2>Dashboard</h2> </header> <div class="w3-content w3-padding"> <table class="w3-table w3-bordered"> <tr style="background-color:#E4EBC5; color:orangered;"> <th>ID</th> <th>Details</th> <th>Location</th> <th>Status</th> <th>Comment</th> <th colspan="2">Action</th> </tr> <?=$pendingRecs?> </table> </div> </body> </html> Notice: Undefined variable: conn in /opt/lampp/htdocs/new1/apply.php on line 21 Fatal error: Uncaught Error: Call to a member function query() on null in /opt/lampp/htdocs/new1/apply.php:21 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/new1/apply.php on line 21
  10. sir can you please show me how to apply on the code? I am very much new to this
  11. Dear Sir/Madame I am making a website where user can insert data and wait for the admin to approve/reject the form. Now i am stuck with the update status where an admin can submit with a click pending to approval or reject with comments. I am new to PHP programming. Can somebody help me with the issue. Part 1 is inserting the data and part two is fetching the data but i am unable to solve the status approve/reject and comment at the same time on the view.php? page. Kindly help. Thank you. <?php $host="localhost"; $username="root"; $pass=""; $db="ems1"; $conn=mysqli_connect($host,$username,$pass,$db); if(!$conn){ die("Database connection error"); } // insert query for register page if(isset($_REQUEST['proposal'])) { $details=$_POST['details']; $location=$_POST['location']; $date=$_POST['date']; $time=$_POST['time']; $status="Pending"; $comment=$_POST['comment']; $query="INSERT INTO `proposal` (`details`,`location`,`date`,`time`,`status`,`comment`) VALUES ('$details','$location','$date','$time','$status','$comment')"; $res=mysqli_query($conn,$query); if($res){ $_SESSION['success']="Not Inserted successfully!"; header('Location:'); }else{ echo "Leave not Applied, please try again!"; } } ?> <div class="col-xs-6 col-xs-push-3 well"> <form class="form-horizontal" method="post" action="" > <input type="hidden" name="proposal" value=""> <fieldset> <legend>New Proposals </legend> <!----left box-----------> <!----right box-----------> <div class="col-xs-9"> <div class="form-group"> <label for="inputEmail" class="col-lg-3"><b>Details:</b></label> <div class="col-lg-9"> <input type="text" name="details" class="form-control"> </div> </div> <div class="form-group"> <label for="inputEmail" class="col-lg-3"><b>Location:</b></label> <div class="col-lg-9"> <input type="text" name="location" class="form-control" > </div> </div> <div class="form-group"> <label for="inputEmail" class="col-lg-3"><b>Date:</b></label> <div class="col-lg-9"> <input type="date" name="date" class="form-control"> </div> </div> <div class="form-group"> <label for="inputEmail" class="col-lg-3"><b>Time:</b></label> <div class="col-lg-9"> <input type="time" name="time" class="form-control" > </div> </div> <div class="col-lg-9"> <input type="hidden" name="status" class="form-control" > </div> </div> <div class="form-group"> <label for="inputEmail" class="col-lg-3"><b></b></label> <div class="col-lg-9"> <input type="hidden" name="comment" class="form-control"> </div> </div> </div> <div class="form-group"> <div class="col-lg-12"> <button type="reset" class="btn btn-default">Cancel</button> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> </fieldset> </form> </div> </div> <body> <h2 style="text-align:center; color:orangered;"> DASHBOARD </h2> <table> <h3> <tr style="background-color:#E4EBC5; color:orangered;"> <th>ID</th> <th>Details</th> <th>Location</th> <th>Status</th> <th>Comment</th> </tr> </h3> </table> <?Php //////////////////////////////////////////// require "dbconfig.php"; // MySQL connection string $count="SELECT id,details,location,time,status,comment FROM proposal"; if($stmt = $connection->query($count)){ while ($nt = $stmt->fetch_assoc()) { echo " <body> <table> <tr> <td><a href=view.php?id=$nt[id]>$nt[id]</a></td> <td>$nt[details]</td> <td>$nt[location]</td> <td>$nt[status]</td> <td>$nt[comment]</td> </tr> </table> </body> "; } }else{ echo $connection->error; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.