Jump to content

Moorcam

Members
  • Posts

    155
  • Joined

  • Last visited

Everything posted by Moorcam

  1. Been here a while and can't remember posting anything in here so thought I had better. Anyways, I am Dan. 50 years old. Anyone who says that life begins at 40 and 50 is the new 21 has no idea. I am Irish. Grew up in a lovely market town in the South East called Dungarvan. Loved it there. I now live in Central Victoria, Australia and have done for almost 14 years. I guess my coding and dev days started many centuries ago. My first taste of any type of development was in school on an old Apple computer where the class created a messaging type thing that only sent messages from one computer to the other. It was absolute shite but at 14 years of age we thought it was amazing. From there I took an interest in website design and hosting and ran a successful VPS Hosting service in Ireland for a number of years while designing websites on the side for clients. I sold that business in 2005 and drank more Guinness than the Brewery could brew and gave up on the whole shebang until about 2+ years ago. Wow, how the coding standards have changed. I am now back to Square One, learning about PHP, JavaScript and this PDO and Bootstrap carry on. 🤔 At the moment I drive Interstate on a regular basis, mostly in Road Coaches and Semi Trucks on an odd occasion. Love it, but want to settle at home. So, myself and an ex- employer of mine are currently working on an application that we hope will allow me to do just that as there is a huge opening in the Market for an app like it here in Australia. Enough said Anyways, pleasure to make your acquaintance.
  2. Is it worth the price though? What does it offer that say, Sublime Text or Visual Studio Code doesn't? Asking for a friend I used Notepad++ for years and recently started to use Sublime Text.
  3. Thought I would add to the list. Been using VentraIP Australia with years. Also used to work for them and still great friends with the owners. Top quality services. http://www.ventraip.com.au
  4. Howdy, Just started to use PDO and loving it so far. Much better than MySQLi. Anyway, would like to know the best reference books available for PHP. If you use reference books, what do you use? Had a google today and found one "The Complete Reference to PHP". Sounded promising but was published in 2007 so not sure if it would be a good buy. Thoughts?
  5. Moorcam

    Video script

    As requinix said, you will need to learn about the workings of CSS and HTML and how they both work together. My advice is to make use of the website w3schools.com and learn these two vital languages. For this to do what you want, wouldn't be surprised if you needed some Javascript too. Post up your HTML with the video in a simple iFrame and playable. Maybe someone here can point you in the right direction.
  6. Not sure if this is what you were looking for but it's what I used when I used MySQLi to upload an image: $image = mysqli_real_escape_string($con, $_FILES['image']['name']); // image file directory $target = "images/".basename($image); if(!empty($_FILES['image']['name'])) { $sql = "UPDATE table SET image='".$image."'"; } $result = mysqli_query($con, $sql); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $msg = "Image uploaded successfully"; }else{ $msg = "Failed to upload image"; } if(!$result){ die('Error: ' . mysqli_error($con)); } else{ $message = ' - <i class="fa fa-check text-success"> Record Updated!</i>'; } } } I know it's not an INSERT but the image upload script should still work. Sorry if this is not what you are looking for. BTW: go to PDO. It's more fun.
  7. Thank you so much man. Really appreciate it. Promise I won't bother you anymore ... until the next issue
  8. Thanks heaps. Now, if there is a scenario where the form needs to be updated but without uploading a new image, at this time it just gets rid of the current image. I need to work out how to prevent that. Previously, before moving to PDO, I had a second insert query inside an if clause. Tried it with this but got an UNEXPECTED else.
  9. Had the sandwich and the coffee. No smoke because I gave them up about 2 weeks ago (God help everyone around me) and had a look at the first line. Changed it to the following: if(!empty($_FILES['image']['name'])) { Works perfectly. No idea why that didn't shout at me earlier. Thank you kindly.
  10. Hi guys, Using the following code to upload an image to a directory. It aint being funky... if ($_FILES['image']['error'] = UPLOAD_ERR_OK) { // image file directory $target = "images/uploads/".basename($_FILES['image']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $msg = "Image uploaded successfully"; $post['image'] = $target; }else{ $msg = "Failed to upload image"; $post['image'] = null; } } else { $post['image'] = null; } Can anyone tell me what's up? Thanks guys
  11. Thanks mate. Will do. Bit of a massive learning curve but no doubt I will get there. Thanks for your help guys.
  12. Just saw this now. Thanks heaps mate. It works. I will get there eventually
  13. Ok, I am having a crack here so please be gentle. include_once('includes/header.php'); if(isset($_POST['submit'])){ $id = trim($_SESSION['id']); //$trn_date = trim($db, date("Y-m-d H:i:s")); //$password = $db->real_escape_string(md5($_POST['password'])); $image = trim($_FILES['image']['name']); $name = trim($_POST['name']); $phone = trim($_POST['phone']); $email = trim($_POST['email']); $address = trim($_POST['address']); $license_number = trim($_POST['license_number']); $position = trim($_POST['position']); $role = trim($_POST['role']); $submittedby = trim($_SESSION["username"]); // image file directory $target = "images/".basename($image); if(!empty($_FILES['image']['name'])) { $stmt = $db->prepare("UPDATE users SET name = ?, email = ?, phone = ?, address = ?, license_number = ?, position = ?, role = ?, submittedby = ?, image = ? WHERE id = ?"); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $msg = "Image uploaded successfully"; }else{ $msg = "Failed to upload image"; } }else{ $stmt = $db->prepare("UPDATE users SET name = ?, email = ?, phone = ?, address = ?, license_number = ?, position = ?, role = ?, submittedby = ? WHERE id = ?"); } $stmt = $db->execute(array($name, $email, $phone, $address, $license_number, $position, $role, $submittedby, $image)); if($stmt->execute()){ echo 'Done'; }else{ echo 'Not Done'; } } The above gives an error: Fatal error: Uncaught Error: Call to undefined method PDO::execute() That's this line: $stmt = $db->execute(array($name, $email, $phone, $address, $license_number, $position, $role, $submittedby, $image)); I am at a complete roadblock here.
  14. Howdy folks, I have decided, after a discussion with Barand, to finally hang up the MySQLi shoes and move over to the dark side of PDO. I am trying to Update a profile, for example, but it is not working. No errors or anything. New to PDO so would love some help on figuring out where I am going wrong. Probably everywhere knowing me lol. Here is the dreaded code: if(isset($_POST['submit'])){ $id = trim($_SESSION['id']); //$trn_date = trim($db, date("Y-m-d H:i:s")); //$password = $db->real_escape_string(md5($_POST['password'])); $image = trim($_FILES['image']['name']); $name = trim($_POST['name']); $phone = trim($_POST['phone']); $email = trim($_POST['email']); $address = trim($_POST['address']); $license_number = trim($_POST['license_number']); $position = trim($_POST['position']); $role = trim($_POST['role']); $submittedby = trim($_SESSION["username"]); // image file directory $target = "images/".basename($image); if(!empty($_FILES['image']['name'])) { $sql = "UPDATE users SET name = :name, email = :email, phone = :phone, address = :address, license_number = :license_number, position = :position, role = :role, submittedby = :submittedby, image = :image"; }else{ $sql = "UPDATE users SET name = :name, email = :email, phone = :phone, address = :address, license_number = :license_number, position = :position, role = :role, submittedby = :submittedby"; } $stmt= $db->prepare($sql); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $msg = "Image uploaded successfully"; }else{ $msg = "Failed to upload image"; } if(!$stmt){ if ($stmt->execute()){ $message = ' <i class="fa fa-check text-danger"> Something went wrong please contact the server admin.</i>'; } else{ $message = ' <i class="fa fa-check text-success"> Record Updated!</i>'; } } } Any help folks would be appreciated
  15. Working. Mate you are a legend. $sql = "INSERT INTO timesheets (user_id, week_ending, timesheet_comment) VALUES ('$user_id', '$week_ending', '$timesheet_comment')"; if (mysqli_multi_query($con, $sql)) { $last_id = $con->insert_id; } $sql2 = "INSERT INTO stafftime (sheet_id, staff_date, time_start, time_end, break_time) VALUES ('$last_id', '$staff_date', '$time_start', '$time_end', '$break_time')"; if (mysqli_multi_query($con, $sql2)) { $message = '<p class="text-success"><i class="fa fa-check"></i> - Timesheet Submitted Successfully</p>'; } else { $message = '<p class="text-danger"><i class="fa fa-check"> Error:'. $sql2 . '<br>' . mysqli_error($con).'</p>'; } mysqli_close($con); }
  16. That's what I was wondering how I do. How do I get those IDs to be the same in different tables? I did search Google about that but could find nothing.
  17. *Red Faced* Sorry. I thought you meant a Var dump Here you go. Hope this is what you are after: CREATE TABLE `stafftime` ( `time_id` int(11) NOT NULL, `sheet_id` int(11) NOT NULL, `staff_date` date NOT NULL, `time_start` varchar(20) NOT NULL, `time_end` varchar(20) NOT NULL, `break_time` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `stafftime` -- INSERT INTO `stafftime` (`time_id`, `sheet_id`, `staff_date`, `time_start`, `time_end`, `break_time`) VALUES (1040, 141826, '2021-09-19', '06:00', '17:00', '1:00'), (1041, 671766, '2021-09-19', '09:30', '17:30', '1:00'), (1042, 1080, '2021-09-19', '09:30', '17:30', '1:00'); -- -------------------------------------------------------- -- -- Table structure for table `timesheets` -- CREATE TABLE `timesheets` ( `timesheet_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `week_ending` datetime NOT NULL, `timesheet_comment` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `timesheets` -- INSERT INTO `timesheets` (`timesheet_id`, `user_id`, `week_ending`, `timesheet_comment`) VALUES (1050, 9, '2021-10-10 00:00:00', 'Just a test'), (1051, 9, '2021-09-19 00:00:00', 'Just a test'), (1052, 9, '2021-09-19 00:00:00', 'Just a test'); -- -- Indexes for dumped tables -- -- -- Indexes for table `stafftime` -- ALTER TABLE `stafftime` ADD PRIMARY KEY (`time_id`), ADD KEY `timesheet_id` (`sheet_id`); -- -- Indexes for table `timesheets` -- ALTER TABLE `timesheets` ADD PRIMARY KEY (`timesheet_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `stafftime` -- ALTER TABLE `stafftime` MODIFY `time_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1043; -- -- AUTO_INCREMENT for table `timesheets` -- ALTER TABLE `timesheets` MODIFY `timesheet_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1053; COMMIT;
  18. Here is a var_dump of the $result object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(12) ["lengths"]=> array(12) { [0]=> int(1) [1]=> int(4) [2]=> int(19) [3]=> int(1) [4]=> int(7) [5]=> int(0) [6]=> int(0) [7]=> int(0) [8]=> int(0) [9]=> int(0) [10]=> int(0) [11]=> int(0) } ["num_rows"]=> int(3) ["type"]=> int(0) } object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(12) ["lengths"]=> array(12) { [0]=> int(1) [1]=> int(4) [2]=> int(19) [3]=> int(1) [4]=> int(7) [5]=> int(0) [6]=> int(0) [7]=> int(0) [8]=> int(0) [9]=> int(0) [10]=> int(0) [11]=> int(0) } ["num_rows"]=> int(3) ["type"]=> int(0) } object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(12) ["lengths"]=> array(12) { [0]=> int(1) [1]=> int(4) [2]=> int(19) [3]=> int(1) [4]=> int(7) [5]=> int(0) [6]=> int(0) [7]=> int(0) [8]=> int(0) [9]=> int(0) [10]=> int(0) [11]=> int(0) } ["num_rows"]=> int(3) ["type"]=> int(0) } And a var_dump of $sql string(494) "SELECT timesheets.user_id, timesheets.timesheet_id, timesheets.week_ending , users.id, users.name , stafftime.time_id, stafftime.sheet_id, stafftime.staff_date, stafftime.time_end, stafftime.time_start, stafftime.break_time , timediff(timediff(time_end, time_start), break_time) as hrs_worked FROM timesheets LEFT JOIN users ON timesheets.user_id = users.id LEFT JOIN stafftime ON stafftime.sheet_id = timesheets.timesheet_id WHERE id=9" string(494) "SELECT timesheets.user_id, timesheets.timesheet_id, timesheets.week_ending , users.id, users.name , stafftime.time_id, stafftime.sheet_id, stafftime.staff_date, stafftime.time_end, stafftime.time_start, stafftime.break_time , timediff(timediff(time_end, time_start), break_time) as hrs_worked FROM timesheets LEFT JOIN users ON timesheets.user_id = users.id LEFT JOIN stafftime ON stafftime.sheet_id = timesheets.timesheet_id WHERE id=9" string(494) "SELECT timesheets.user_id, timesheets.timesheet_id, timesheets.week_ending , users.id, users.name , stafftime.time_id, stafftime.sheet_id, stafftime.staff_date, stafftime.time_end, stafftime.time_start, stafftime.break_time , timediff(timediff(time_end, time_start), break_time) as hrs_worked FROM timesheets LEFT JOIN users ON timesheets.user_id = users.id LEFT JOIN stafftime ON stafftime.sheet_id = timesheets.timesheet_id WHERE id=9" I really appreciate your time and effort man.
  19. Thanks mate. Great reading. Very informative. It appears my query is not getting the data from stafftime. Populating from the other two tables fine but anything from stafftime is just not happening. $session = $_SESSION['ID']; $sql = "SELECT timesheets.user_id, timesheets.timesheet_id, timesheets.week_ending , users.id, users.name , stafftime.time_id, stafftime.sheet_id, stafftime.staff_date, stafftime.time_end, stafftime.time_start, stafftime.break_time , timediff(timediff(time_end, time_start), break_time) as hrs_worked FROM timesheets LEFT JOIN users ON timesheets.user_id = users.id LEFT JOIN stafftime ON stafftime.sheet_id = timesheets.timesheet_id WHERE id=$session"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) {
  20. Moorcam

    Video script

    You will probably need something like this. But will need to work out the actual outline of the Frame to make it look like a TV: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_responsive_iframe_169
  21. if(isset($row['time_start']) && $row['time_end'] && $row['break_time'] != "") { $time_start = new DateTime($row['time_start']); $time_end = new DateTime($row['time_end']); list($h, $m) = explode(":", $row['break_time']); $break_time = new DateInterval("PT{$h}H{$m}M"); $time_worked = $time_start->add($break_time)->diff($time_end); echo $time_worked; } Have also tried this and nothing.
  22. Howdy guys, First of all, thanks so much for your help so far, especially yesterday. My wife and kids would tell you I was ropeable. Following Barand's advice and idea on my previous post, I have decided to break things up and put them into separate tables to make it easier to process. All is working fine but Hours Worked do not WERK (work), I am trying an accent Here's the code that called the timesheet submitted by a driver for one day. It is showing to the submitter based on their session id. $session = $_SESSION['ID']; $sql = "SELECT timesheets.*, users.*, staff_time.*, timediff(timediff(time_end, time_start), break_time) as hrs_worked FROM timesheets LEFT JOIN users ON timesheets.user_id = users.id LEFT JOIN staff_time ON timesheets.timesheet_id = staff_time.sheet_id WHERE id=$session"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { Here is where I am trying to display the hours worked: <td><?php echo $row['hrs_worked']; ?></td> But nothing shows. No errors, nothing in Console either. I am obviously doing this wrong. As mentioned in my last post, I am new to this JOIN thingy-ma-jig. I know this following piece is meant to calculate between start, end and break. Not sure if that's happening either. timediff(timediff(time_end, time_start), break_time) as hrs_worked Any guidance, as always is appreciated.
  23. Got it: $sql = "SELECT timesheets.*, users.*, staff_time.*, timediff(timediff(time_end, time_start), break_time) as hrs_worked FROM timesheets LEFT JOIN users ON timesheets.user_id = users.id LEFT JOIN staff_time ON timesheets.timesheet_id = staff_time.timesheet_id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { Thanks guys for your patience etc. Had never heard of JOIN this and that until it was mentioned on these forums a couple months ago :D
  24. $sql = "SELECT timesheets.*, users.*, staff_time.* FROM timesheets INNER JOIN users ON users.user_id = timesheets.user_id INNER JOIN staff_time ON staff_time.timesheet_id = timesheet.timesheet_id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { Still no good.
×
×
  • 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.