Jump to content

Adamhumbug

Members
  • Posts

    597
  • Joined

  • Last visited

Everything posted by Adamhumbug

  1. Hi All, I have the following table (ssm_chat_link) +---------+---------+-------------------+ | chat_id | user_id | chat_surrogate_id | +---------+---------+-------------------+ | 1 | 1 | 1 | | 1 | 2 | 2 | | 2 | 1 | 3 | | 2 | 3 | 4 | +---------+---------+-------------------+ I am wanting to select the user_id of every one that shares a chat_id with user_id = 1 I will then user this info to get the user names of these people and run a foreach in my php to create a button per person. I am very stuck with this and although i am sure this is very simple once you know how....i do not. Your help is always appreciated.
  2. Thanks, i will have a further look at this then.
  3. Yes i had a look at this example. Am i correct in thinking that this only loads notifications on page load. If that is correct, would this mean that i would have to run this code to look for new notifications on every page. Also would i be correct in thinking that the notifications would not appear unless the users is navigating around pages. Unless a page can reload, there will be no notifications?
  4. HI all, I am building a php application and i am wanting to use notifications. At the moment i am just wanting to understand the methodology behind this. I dont necessarily have a use case for these notifications yet but i am going to base it off of the following: A user submits something to the database, another user gets a notifications that this has happened. I see the notifications being something appearing in the header bar (saying "you have a notification"...) I know that i will need to use ajax for this and JS/JQ but i am not really sure where to start with this. I have done some research and have come up a little blank. My main question at the moment is how does the submission of data to the database trigger the notification? As always and help here is appreciated. Kind Regards Adam
  5. I have the following script in here if this is going to help function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev .dataTransfer .setData("text", ev.target.id); } function drop(ev) { ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); }
  6. ok thanks for that if an admin would be so kind as to move this, it would be appreciated.
  7. Hi, not sure if this is more of a JS or PHP question but here goes. I have a form that populates people into a box. There name is on a div that looks like a button. Also inside the div are 2 hidden inputs. I plan on dragging some people from box 1 into box 2. When moving, i would like everyone in box 2 to have their second hidden input to be changed so when i submit it will be clear who was in which box. It currently looks like this when populated if that helps anyone. <div class="mt-3 col-6"> <div class="container border border-dark p-1 h-50" ondrop="drop(event)" ondragover="allowDrop(event)"> <div class="alert alert-warning text-center">Making Own Way</div> <div id="2" class="btn btn-primary m-1" data-id="2" data-role="Manager" draggable="true" ondragstart="drag(event)"> <input class="staff" name="staff[]" type="hidden" value="2"> <input class="transMethod" name="trans[]" type="hidden" value="mow"> Chelsea Hockley</div><div id="16" class="btn btn-primary m-1" data-id="16" data-role="Manager" draggable="true" ondragstart="drag(event)"> <input class="staff" name="staff[]" type="hidden" value="16"> <input class="transMethod" name="trans[]" type="hidden" value="mow"> TEST MANAGER</div> </div> </div> <div class="mt-3 col-6"> <div class="container container border border-dark p-1 h-50" ondrop="drop(event)" ondragover="allowDrop(event)"> <div class="alert alert-primary text-center">Need Transport Daily</div> </div> </div>
  8. When i click my submit button i am posting the following. Array ( [submitStaffOrder] => [staffMember] => Array ( [0] => 2 [1] => ANYCHEF1 ) [date] => Array ( [0] => 2020-02-18 [1] => 2020-02-18 ) [startTime] => Array ( [0] => 11:01 [1] => 10:10 ) [finishTime] => Array ( [0] => 11:01 [1] => 10:01 ) [delExisting] => Array ( [0] => [1] => toDel ) ) I would like to update/insert if delExisting is blank and delete if it has toDel in there. I have the following but i am pretty sure the if is not working. $date = $_POST['date']; $stime = $_POST['startTime']; $ftime = $_POST['finishTime']; $del = $_POST['delExisting']; $staff = $_POST['staffMember']; $stmt = $conn -> prepare(" INSERT IGNORE INTO ssm_staff_order (job_id, staff_id, staff_start_time, staff_finish_time, staff_start_date, staff_finish_date) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE staff_start_time = VALUES(staff_start_time), staff_finish_time = VALUES(staff_finish_time); "); $delstmt = $conn -> prepare(" DELETE FROM ssm_staff_order WHERE staff_id = ? AND job_id = ? AND staff_start_date = ? "); foreach ($staff as $key => $staffId) { if ($del == '') { $start = $date[$key].' '.$stime[$key]; $finish = $date[$key].' '.$ftime[$key]; $stmt -> bind_param('isssss', $jid, $staffId, $start, $finish, $date[$key], $date[$key]); $stmt -> execute(); } if ($del == 'toDel') { $delstmt -> bind_param('sis', $staffId, $jid, $date[$key]); $delstmt -> execute(); } } } Can i do what i am trying to do or am i way off here? I struggle with arrays
  9. Thanks for that - will be useful.
  10. When i do the following: while ($stmt -> fetch()) { $user =[$role, $fn, $ln, $id]; } i only get one result and i know the sql is pulling 3 results. I tried using .= but that give me an array to string error.
  11. Hi All, I have a select statement $stmt = $conn -> prepare(' SELECT u.user_firstname, u.user_lastname, so.staff_id, r.role_name FROM ssm_staff_order so INNER JOIN ssm_user u on so.staff_id = u.user_id INNER JOIN ssm_role r on u.user_role_id = r.role_id WHERE job_id = ? '); $stmt -> bind_param('i', $jid); $stmt -> execute(); $stmt -> bind_result($fn, $ln, $id, $role); The result looks like this +----------------+---------------+----------+-----------+ | user_firstname | user_lastname | staff_id | role_name | +----------------+---------------+----------+-----------+ | FName | LName | 8 | Chef | | jon | smith | 15 | Manager | | Chelsea | Hockley | 2 | Manager | +----------------+---------------+----------+-----------+ I am wanting to build an array so that i can foreach the result with the people under the header of their role. I know this is not difficult but i am going around and around with it and clearly missing the key part. As always your help is appreciated.
  12. A bit of working out here but that worked perfectly. Thank You
  13. I have an array that has comma sep values. I am wanting to run a select statement that includes a NOT IN function. SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? and where user_id NOT IN(?) Is this possible, oir does the ? just represent a literal string. If so do i need to convert the array to a string before running the above?
  14. Thanks for this.
  15. I think i have answered my own question about 10 seconds after posting this. if(!empty($_SESSION['message'])){ doesnt seem to generate the same message that if($_SESSION['message'] !=''){ did Thanks anyway
  16. I have a message bar that when a page reloads, a message appears at the top of the screen. I feed the message with session variables that are set at the end of the action (submission for example) When the page reloads the message displays and then unsets the session variables. The issue is when the page first loads (when it has never run an action) and gives me the Notice: Undefined index: message. My question is, how can i handle the session being blank when the page first loads and thus not get the notice.
  17. <a onclick='delModal($miid);' data-toggle='modal' href='#delConfModal' data-id='$miid' class='delButton btn btn-danger'>Delete Menu Item</a> seems to be working
  18. i think i have corrected this by passing the menu item id in the function call
  19. undefined - the button has a data ID though and i am trying to get it in the same way as on the other ajax.
  20. No it hasnt changed anything having the quotes in there.
  21. ajax=two is getting sent but nothing else
  22. Erm, no it doesnt
  23. It is now showing the response which is nice. I am however getting Undefined index: id on the switch calling the second function.
  24. ahhhh, and i thought i was doing so well. Ok ill have another look at resorting it. I have chnaged the function to just be a function rather than looking for a click. I have put an onclick on the button that is being created.
×
×
  • 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.