Jump to content

ianhaney50

Members
  • Posts

    261
  • Joined

  • Last visited

  • Days Won

    1

ianhaney50 last won the day on August 17 2016

ianhaney50 had the most liked content!

ianhaney50's Achievements

Member

Member (2/5)

1

Reputation

1

Community Answers

  1. Hi Thank you for the reply, appreciate it Sorry yeah I realised that shortly after posting my question, so sorry, is perfect now
  2. Hi I just found another little issue, not sure why it is outputting all the records as before it just outputted the id record I click on The code for the specific id record is below <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>IT Done Right Admin View Repair Tracking</title> <link rel="stylesheet"href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/blitzer/jquery-ui.css"/> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" /> <link rel="stylesheet" href="css/print.css" type="text/css" media="print"> </head> <body> <script> var t; window.onload=resetTimer; document.onkeypress=resetTimer; function logout() { alert("You are now logged out.") location.href='../logout.php' } function resetTimer() { clearTimeout(t); t=setTimeout(logout,1800000) //logs out in 30 minutes } </script> <? session_start(); if($_SESSION['user']==''){ header("Location:../index.php"); }else{ include("../config.php"); $sql=$dbh->prepare("SELECT * FROM users WHERE id=?"); $sql->execute(array($_SESSION['user'])); while($r=$sql->fetch()){ echo "<div class='home-content'>"; echo "<center><h2>Hello, ".$r['username']."</h2>"; echo "<a href='../logout.php'>Log Out</a>"; echo "<br><br>"; echo "<a href='../home.php'>Home</a></center>"; echo "</div>"; } } ?> <div class="print"> <div id="logo"> <img src="images/logo/it-done-right.jpg" alt="" title=""> </div> <div style="clear: both;"> <?php // connect to the database include('connect-db.php'); // get the records from the database if ($result = $mysqli->query("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, DATE_FORMAT(exrdate,'%d/%m/%Y') AS exrdate, exrtime, DATE_FORMAT(exstdate,'%d/%m/%Y') AS exstdate, exstime, deltype, comments, cost FROM repairs ORDER BY id")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table while ($row = $result->fetch_object()) { echo "<strong>Repair ID</strong>: " . $row->id; echo "<br><br>"; echo "<strong>Customer Name</strong>: " . $row->customer_name; echo "<br><br>"; echo "<strong>Customer Email</strong>: " . $row->customer_email; echo "<br><br>"; echo "<strong>Customer Phone</strong>: " . $row->customer_phone; echo "<br><br>"; echo "<strong>Computer Make</strong>: " . $row->computer_make; echo "<br><br>"; echo "<strong>Computer Model</strong>: " . $row->computer_model; echo "<br><br>"; echo "<strong>Assigned to Technician</strong>: " . $row->technician; echo "<br><br>"; echo "<strong>Repair Status</strong>: " . $row->status; echo "<br><br>"; echo "<strong>Expected Repair Date</strong>: " . $row->exrdate; echo "<br><br>"; echo "<strong>Expected Repair Time</strong>: " . $row->exrtime; echo "<br><br>"; echo "<strong>Expected Start Date</strong>: " . $row->exstdate; echo "<br><br>"; echo "<strong>Expected Start Time</strong>: " . $row->exstime; echo "<br><br>"; echo "<strong>Delivery Type</strong>: " . $row->deltype; echo "<br><br>"; echo "<strong>Comments</strong>: " . $row->comments; echo "<br><br>"; echo "<strong>Repair Cost</strong>: " . '£' . $row->cost; echo "</div>"; echo "</div>"; echo "<br><br>"; echo "<td><a href='repairs-tracking.php?id=" . $row->id . "'>Edit</a></td>"; echo "<br><br>"; } } // if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli->error; } // close database connection $mysqli->close(); ?> <a href="view-repairs-tracking.php">Back to view all repairs tracking</a> | <a href="#" onclick="window.print();return false;">Print this page</a> | <a href="repairs-tracking.php">Add New Repair For Tracking</a> </body> </html>
  3. So sorry, I thought the easier way would be to make the datepicker be in standard format of yy/mm/dd code and tested it and works perfect now and now displays on the page as 28/11/2015 so is perfect now, so sorry for being a pain
  4. Hi Barand I just added that to the INSERT query so now looks like the following if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, (STR_TO_DATE($exstdate, '%d/%m/%y') ), exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) I selected 8/11/2015 within the datepicker but has outputted it as 10/4/2015
  5. I renamed the $date to the name of $exrdate and it worked but it outputted the date as 10/4/2015 instead of 4/10/2015 and also it should be 4/11/2015 not 4/10/2015 also how do I get that to work for a second date as well as I have exrdate and exstdate
  6. I just tried that and didn't work still, I added it directly above the insert query
  7. Thank you so much, works perfect I just found another little issue when testing, the record date is being inserted into the mysql table as 00/00/0000 instead of the actual date, I am using datepicker, the INSERT query is below if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) The datepicker coding is below <script> $(function() { $( "#exrdate" ).datepicker({ showButtonPanel: true, dateFormat: "dd/mm/yy", showOn:"both" }); }); $(function() { $( "#exstdate" ).datepicker({ showButtonPanel: true, dateFormat: "dd/mm/yy", showOn:"both" }); }); </script> It was working before but not now for some reason the data type in the mysql table is date and has no NULL or default
  8. Thank you so much, works perfect I just found another little issue when testing, the record date is being inserted into the mysql table as 00/00/0000 instead of the actual date, I am using datepicker, the INSERT query is below // insert the new record into the database if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))
  9. Hi I am trying to work out how to display a specific number of characters in a echo row, the line looks like the following echo "<td>" . $row->comments . "</td>"; Thank you in advance Sorry I did look on Google but couldn't see a way to do it with the similar coding I have above
  10. Sorry have it solved now
  11. I did notice the form on the edit page has the method post instead of get so am guessing is best to replace $_GET with $_POST
  12. Below is the view page that calls the edit page <?php $host = ''; $user = ''; $password = ''; $dname = ''; $db = new mysqli($host, $user, $password, $dname); if ($db->connect_errno) { echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error; } $sql = "SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments FROM repairs"; $result_db = $db->query($sql) or die('Error perform query!'); ?> <table border="1"> <tr> <th>Repair ID</th> <th>Customer Name</th> <th>Customer Email</th> <th>Customer Phone</th> <th>Computer Make</th> <th>Computer Model</th> <th>Technician</th> <th>Status</th> <th>Expected Repair Date</th> <th>Expected Repair Time</th> <th>Expected Start Date</th> <th>Expected Start Time</th> <th>Delivery Type</th> <th>Comments</th> <th>Update</th> </tr> <?php while ($r = $result_db->fetch_object()) { $update = "admin/repairs-tracking/edit-repair-tracking.php?id={$r->id}"; echo '<tr>'; echo '<td>' . $r->id . '</td>'; echo '<td>' . $r->customer_name . '</td>'; echo '<td>' . $r->customer_email . '</td>'; echo '<td>' . $r->customer_phone . '</td>'; echo '<td>' . $r->computer_make . '</td>'; echo '<td>' . $r->computer_model . '</td>'; echo '<td>' . $r->technician . '</td>'; echo '<td>' . $r->status . '</td>'; echo '<td>' . $r->exrdate . '</td>'; echo '<td>' . $r->exrtime . '</td>'; echo '<td>' . $r->exstdate . '</td>'; echo '<td>' . $r->exstime . '</td>'; echo '<td>' . $r->deltype . '</td>'; echo '<td>' . $r->comments . '</td>'; echo "<td><a href='/{$update}'>Update</a></td>"; echo '</tr>'; } $db->close(); ?> </table>
  13. Hi I have added in the var dump line and that outputs the following array(1) { ["id"]=> string(2) "20" } So $_POST is better then, that right? If so do I just change $_GET to $_POST
  14. Hi I am trying to populate a form ready to update the data and have managed to get the id number displaying in the input field but for every other input field, it displays the following <br /><b>Notice</b>: Undefined index: customer_name in <b>/home/sites/it-doneright.co.uk/public_html/admin/repairs-tracking/edit-repair-tracking.php</b> on line <b>40</b><br /> I really don't get it or see where I am going wrong with it, below is the whole code on the edit-repair-tracking.php page <form action="update-admin-repair-tracking.php" method="post"> Repair ID: <input value="<?= $_GET['id'] ?>" name="id"/> Customer Name: <input type="text" name="customer_name" value="<?= $_GET['customer_name'] ?>"> Customer Email: <input type="text" name="customer_email" value="<?= $_GET['customer_email'] ?>"> Customer Phone: <input type="text" name="customer_phone" value="<?= $_GET['customer_phone'] ?>"> Computer Make: <input type="text" name="computer_make" value="<?= $_GET['computer_make'] ?>"> Computer Model: <input type="text" name="computer_model" value="<?= $_GET['computer_model'] ?>"> Technician: <select name="technician" id="technician"> <option value="Not Assigned">Not Assigned</option> <option value="Phil Roskams">Phil Roskams</option> <option value="Ian Haney">Ian Haney</option> </select> Status: <select name="status" id="status"> <option value="Not Started">Not Started</option> <option value="In Queue">In Queue</option> <option value="On Bench / Working">On Bench / Working</option> <option value="Awaiting Parts">Awaiting Parts</option> <option value="Awaiting Customer">Awaiting Customer</option> <option value="Completed">Completed</option> </select> Expected Repair Date: <input type="date" name="exrdate" value="<?= $_GET['exrdate'] ?>"> Expected Repair Time: <input type="time" name="exrtime" value="<?= $_GET['exrtime'] ?>"> Expected Start Date<input type="date" name="exstdate" value="<?= $_GET['exstdate'] ?>"> Expected Start Time: <input type="time" name="exstime" value="<?= $_GET['exstime'] ?>"> Delivery Type: <select name="deltype" id="deltype"> <option value="Self Pickup">Self Pickup</option> <option value="Deliver to Customer">Delivery to Customer</option> </select> Comments: <br> <textarea name="comments" cols="50" rows="3" id="comments"><?= $_GET['comments'] ?></textarea> <input type="submit" name="submit"> </form> </body> </html> Can someone help me please as been trying to work out what I am missing for a good hour now Thank you in advance would the issue be with this page or the view tracking php page where the records are displayed?
  15. So sorry it is my fault, I am so stupid, there was no data for id 17 but was sure there was, so sorry, let me just slap myself, so sorry
×
×
  • 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.