i want data db , show table shows blank rows , number of row entries no information @ all?
<form method="post" action="index.php"> <select name="month" id="month"> <option></option> <option value="1">january</option> <option value="2">february</option> <option value="3">march</option> <option value="4">april</option> <option value="5">may</option> <option value="6">june</option> <option value="7">july</option> <option value="8">august</option> <option value="9">september</option> <option value="10">october</option> <option value="11">november</option> <option value="12">december</option> </select> <input type="submit" value="submit" name="submit"/>
i think problem here please help
<?php $hostname="localhost"; $username="root"; $password=""; $dbname="testproduct"; $db = new mysqli($hostname, $username, $password, $dbname); $stmt = $db->stmt_init(); // if($stmt->prepare("select fname,lname,checkin,checkout,rrate,reservefee,datepaid,modepayment,stats tblguest month(checkin)//checkin name of row database = ?")) { // if(!$stmt->bind_param('s', $month)) { //if bind fails, display error printf("errormessage: %s\n", $stmt->error); } $month = isset($_post['month']) ? $db->real_escape_string($_post['month'])//this 'month' select name : ''; if(!$stmt->execute()) { printf("errormessage: %s\n", $stmt->error); } if(!$stmt->bind_result($fname,$lname,$checkin,$checkout,$rrate,$reservefee,$datepaid,$modepayment,$stats))//name of db rows , information want show on web { printf("errormessage: %s\n", $stmt->error); }
done editing table working edit button in should pre-populated data data base showing blank textbox
while($stmt->fetch()) { ?> <tr> <td><?php echo $fname; ?></td> <td><?php echo $lname; ?></td> <td><?php echo $checkin; ?></td> <td><?php echo $checkout; ?></td> <td><?php echo $rrate; ?></td> <td><?php echo $reservefee; ?></td> <td><?php echo $datepaid; ?></td> <td><?php echo $modepayment; ?></td> <td><?php echo $stats; ?></td> <td align="center"> <a id="<?php echo $fname.$lname ?>" class="edit-link" href="#" title="edit"> <img src="edit.png" width="20px" /> </a></td> <td align="center"><a id="<?php echo $fname.$lname ?> "class="delete-link" href="#" title="delete"> <img src="delete.png" width="20px" /> </a></td> </tr> <?php } } ?> </tbody> </table> </div> </div>
edit_form.php tried echo $fname textbox got input of notice: undefined variable: fname
<?php include_once 'dbconfig.php'; if($_get['edit_id']) { $id = $_get['edit_id']; $stmt=$db_con->prepare("select * tblguest id=:id"); $stmt->execute(array(':id'=>$id)); $row=$stmt->fetch(); } ?> <style type="text/css"> #dis{ display:none; } </style> <div id="dis"> </div> <form method='post' id='emp-updateform' action='#'> <table class='table table-bordered'> <input type='hidden' name='id' value='<?php echo $id; ?>' /> <tr> <td>first name</td> <td><input type='text' name='fname' class='form-control' value='<? php echo $fname; ?>' required></td> </tr> <tr> <td>last name</td> <td><input type='text' name='lname' class='form-control' value='<?php echo $row['lname']; ?>' required></td> </tr> <tr> <td>contact number</td> <td><input type='text' name='contactnum' class='form-control' value='<?php echo $row['contactnum']; ?>' required></td> </tr> <tr> <td>email</td> <td><input type='text' name='email' class='form-control' value='<?php echo $row['email']; ?>' required></td> </tr> <tr> <td>check in date</td> <td><input type='date' name='checkin' class='form-control' value='<?php echo $row['checkin']; ?>' required></td> </tr> <tr> <td>check out date</td> <td><input type='date' name='checkout' class='form-control' value='<?php echo $row['checkout']; ?>' required></td> </tr> <tr> <td>room rate</td> <td><input type='text' name='rrate' class='form-control' value='<?php echo $row['rrate']; ?>' required /></td> </tr> <tr> <td>reservation fee</td> <td><input type='text' name='reservefee' class='form-control' value='<?php echo $row['reservefee']; ?>' required /></td> </tr> <tr> <td> a.date of payment</td> <td><input type='date' name='datepaid' class='form-control' value='<?php echo $row['datepaid']; ?>' required /></td> </tr> <tr> <td> b.mode of payment</td> <td><select name='modepayment' class='form-control' value='<?php echo $row['modepayment']; ?>' required > <option value="cash">cash</option> <option value="bank deposit">bank deposit</option> </select></td> </tr> <tr> <td>balance</td> <td><input type='text' name='balance' class='form-control' value='<?php echo $row['balance']; ?>' required /></td> </tr> <tr> <td> a.date of payment</td> <td><input type='date' name='balpayment' class='form-control' value='<?php echo $row['balpayment']; ?>' required /></td> </tr> <tr> <td> b.mode of payment</td> <td><select name='balmodepay' class='form-control' value='<?php echo $row['balmodepay']; ?>' required > <option value="cash">cash</option> <option value="bank deposit">bank deposit</option> </select></td> </tr> <tr> <td>status</td> <td><select name='stats' class='form-control' value='<?php echo $row['stats']; ?>' required > <option value="reserved">reserved</option> <option value="check in">check in</option> <option value="check out">check out</option> <option value="canceled">canceled</option> <option value="done">done</option> </select></td> </tr> <tr> <td colspan="2"> <button type="submit" class="btn btn-primary" name="btn-update" id="btn-update"> <span class="glyphicon glyphicon-plus"></span> save updates </button> </td> </tr> </table>
i don't have idea on what's happening
update.php
<?php require_once 'dbconfig.php'; if($_post) { $id = $_post['id']; $fname = $_post['fname']; $lname = $_post['lname']; $contactnum = $_post['contactnum']; $email = $_post['email']; $checkin = $_post['checkin']; $checkout = $_post['checkout']; $rrate = $_post['rrate']; $reservefee = $_post['reservefee']; $datepaid = $_post['datepaid']; $modepayment = $_post['modepayment']; $balance = $_post['balance']; $balpayment = $_post['balpayment']; $balmodepay = $_post['balmodepay']; $stats = $_post['stats']; $stmt = $db_con->prepare("update tblguest set fname=:fn, lname=:ln, contactnum=:cn, email=:em, checkin=:ci, checkout=:co, rrate=:rr, reservefee=:rf, datepaid=:dp, modepayment=:mp, balance=:bl, balpayment=:bp, balmodepay=:bm, stats=:st id=:id"); $stmt->bindparam(":fn", $fname); $stmt->bindparam(":ln", $lname); $stmt->bindparam(":cn", $contactnum); $stmt->bindparam(":em", $email); $stmt->bindparam(":ci", $checkin); $stmt->bindparam(":co", $checkout); $stmt->bindparam(":rr", $rrate); $stmt->bindparam(":rf", $reservefee); $stmt->bindparam(":dp", $datepaid); $stmt->bindparam(":mp", $modepayment); $stmt->bindparam(":bl", $balance); $stmt->bindparam(":bp", $balpayment); $stmt->bindparam(":bm", $balmodepay); $stmt->bindparam(":st", $stats); $stmt->bindparam(":id", $id); if($stmt->execute()) { echo "successfully updated"; } else{ echo "query problem"; } } ?>
you should get errors display because code giving undefined offset warnings , you're not seeing them.
as you'll notice from mysqli_stmt::fetch() manual, returns boolean. trying use $row
, boolean array. instead need use variables assigned in mysqli_stmt::bind_result():
if(!$stmt->bind_result($fname,$lname,$checkin,$checkout,$rrate,$reservefee,$datepaid,$modepayment,$stats)) { printf("errormessage: %s\n", $stmt->error); } while($stmt->fetch()) { ?> <tr> <td><?php echo $fname; ?></td> <td><?php echo $lname; ?></td> <td><?php echo $checkin; ?></td> <td><?php echo $checkout; ?></td> <td><?php echo $rrate; ?></td> <td><?php echo $reservefee; ?></td> <td><?php echo $datepaid; ?></td> <td><?php echo $modepayment; ?></td> <td><?php echo $stats; ?></td> <td align="center"> <a id="<?php echo $fname." ".$lname; ?>" class="edit-link" href="#" title="edit"> <img src="edit.png" width="20px" /> </a></td> <td align="center"><a id="<?php echo $fname." ".$lname; ?>" class="delete-link" href="#" title="delete"> <img src="delete.png" width="20px" /> </a></td> </tr> <?php }
Comments
Post a Comment