Jump to content

Adamhumbug

Members
  • Content Count

    181
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Adamhumbug

  • Rank
    Advanced Member
  1. You are of course correct. Currently it does not allow for this but the next step will be to allow the connection of existing items to a new menu.
  2. haha just for fun: Warning: main(): Couldn't fetch mysqli_stmt in /homepages/29/d742272110/htdocs/actions/submit-new-menu-action.php on line 82 Fatal error: Uncaught mysqli_sql_exception: Column 'menu_item_id' cannot be null in /homepages/29/d742272110/htdocs/actions/submit-new-menu-action.php:83 Stack trace: #0 /homepages/29/d742272110/htdocs/actions/submit-new-menu-action.php(83): mysqli_stmt->execute() #1 {main} thrown in /homepages/29/d742272110/htdocs/actions/submit-new-menu-action.php on line 83 //L69 $ins_i = $conn->prepare(' INSERT INTO ssm_menu_items (menu_item_name) VALUES (?); '); $ins_c = $conn->prepare(' INSERT INTO ssm_menu_connection (menu_id, menu_item_id) VALUES (?,?) '); $ins_i->bind_param('s',$nmItem); $ins_c->bind_param('ii', $menuInsId, $menuItmInsId); foreach ($_POST['newMenuItem'] as $nmItem) { $ins_i->execute(); //L82 $menuItmInsId = $stmt->insert_id; //L83 $ins_c->execute(); } }
  3. I like this a lot. I didnt know this was possible -> every day is a school day. Thanks again.
  4. I think this just about does it. if ($_SERVER['REQUEST_METHOD']=="POST") { ///////////////////// //menu name insert // ///////////////////// $mname = $_POST['newMenuName']; $stmt=$conn->prepare(' INSERT IGNORE INTO ssm_menu (menu_name) VALUES (?); '); $stmt->bind_param('s',$mname); $stmt->execute(); $menuInsId = $stmt->insert_id; echo $menuInsId; $stmt->close(); ///////////////////// //menu item insert // ///////////////////// $menuItemInsertIds = array(); $mitname = $_POST['newMenuItem']; $stmt=$conn->prepare(' INSERT IGNORE INTO ssm_menu_items (menu_item_name) VALUES (?); '); foreach ($_POST['newMenuItem'] as $k => $nmItem) { $mitname = $nmItem; $stmt->bind_param('s',$mitname); $stmt->execute(); $menuItmInsId = $stmt->insert_id; array_push($menuItemInsertIds, $menuItmInsId); } $stmt->close(); /////////////////////////// //menu connection insert // /////////////////////////// $stmt=$conn->prepare(' INSERT IGNORE INTO ssm_menu_connection (menu_id, menu_item_id) VALUES (?,?) '); foreach ($menuItemInsertIds as $k => $miiids) { $stmt->bind_param('ii',$menuInsId, $miiids); $stmt->execute(); $connectionInserId = $stmt->insert_id; echo $connectionInserId; } $stmt->close(); }
  5. I am glad that is the case with the real_escape_string - thanks for pointing that out to me. I have created the array but i now need to loop through it in the final query
  6. Hi, I am creating a new menu (food) in my system. This consists of a menu, menu_items and menu_connection table. I can insert the menu name just fine and return its id just fine. When inserting the menu items, i need to get each of the menu_item_ids to use in the query that inputs the menu_connection. This is what i have so far: if ($_SERVER['REQUEST_METHOD']=="POST") { ///////////////////// //menu name insert // ///////////////////// $mname = mysqli_real_escape_string($conn, $_POST['newMenuName']); $stmt=$conn->prepare(' INSERT IGNORE INTO ssm_menu (menu_name) VALUES (?); '); $stmt->bind_param('s',$mname); $stmt->execute(); $menuInsId = $stmt->insert_id; echo $menuInsId; $stmt->close(); ///////////////////// //menu item insert // ///////////////////// $mitname = $_POST['newMenuItem']; $stmt=$conn->prepare(' INSERT IGNORE INTO ssm_menu_items (menu_item_name) VALUES (?); '); foreach ($_POST['newMenuItem'] as $k => $nmItem) { $mitname = mysqli_real_escape_string($conn, $nmItem); $stmt->bind_param('s',$mitname); $stmt->execute(); $menuItmInsId = $stmt->insert_id; echo $menuItmInsId; } $stmt->close(); /////////////////////////// //menu connection insert // /////////////////////////// $stmt=$conn->prepare(' INSERT IGNORE INTO ssm_menu_connection (menu_id, menu_item_id) VALUES (?,?) '); foreach ($_POST['newMenuItem'] as $k => $nmItem) { $stmt->bind_param('ii',$menuInsId, $menuItmInsId); $stmt->execute(); $connectionInserId = $stmt->insert_id; echo $connectionInserId; } $stmt->close(); } Currently it is inserting each of the items in the connection table with the same id - i understand why but i dont know how to collect up all of the ids to use later
  7. Ok so i have got to the bottom of this. I had a mistake in the name of the file that was being called so it was infact not calling the page i thought it was. Turns out that 1&1 show ads on your domain if you hit a page that doesnt exist - i dont really like that at all but hey ho. Thanks all
  8. Hi All, I just created a new action in php on my site. The action doesnt work yet which is fine but when i try and run it i get the following in inspector/console. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> html, body, #partner, iframe { height:100%; width:100%; margin:0; padding:0; border:0; outline:0; font-size:100%; vertical-align:baseline; background:transparent; } body { overflow:hidden; } </style> <meta content="NOW" name="expires"> <meta content="index, follow, all" name="GOOGLEBOT"> <meta content="index, follow, all" name="robots"> <!-- Following Meta-Tag fixes scaling-issues on mobile devices --> <meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"> </head> <body> <div id="partner"></div> <script type="text/javascript"> document.write( '<script type="text/javascript" language="JavaScript"' + 'src="//sedoparking.com/frmpark/' + window.location.host + '/' + 'IONOSParkingUK' + '/park.js">' + '<\/script>' ); </script> </body> </html> Blocked loading mixed active content “http://pagead2.googlesyndication.com/apps/domainpark/show_afd_ads.js” park.js:14:13 Loading failed for the <script> with source “http://pagead2.googlesyndication.com/apps/domainpark/show_afd_ads.js”. add-new-menu-action.php:38:1 All i have on the add-new-menu-action.php file is <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (session_status() == PHP_SESSION_NONE) { session_start(); } if (!isset($_SESSION['user_id'])){ header("location: index.php"); exit; } // mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // include '../_includes/dbconn.php'; echo "POST is: <pre>" . print_r($_POST,true) . "</pre>"; Is this something i should be worried about. (i am already worried about it) I do not have ads on my site nor is that my intention for the future.
  9. HI Both, Thanks for your info here - before seeing your replies, i wrote the following which seems to do what i want but as you said, it copies all of the content with it. I will have a look at cleaning this up and will post the new version once finalized. i=0; function myF() { console.log(i) var chunk = document.getElementById('newMenuItemLine'+i); var clone = chunk.cloneNode(true); i++; chunk.setAttribute("id", "newMenuItemLine" +i); document.getElementById('wrapper').appendChild(clone); }
  10. Hi All, I have posted something on here before that was a lot more complicated that what i am trying to achieve here. I have not worked through the understanding of this yet so was hoping that a more simple method might give me a better start. I have the following HTML and i am looking to, on button click, add a new line with the same html. This will be part of a form so will need to be able to be submitted. I have been playing around with jquery but as i am learning i prefer javascript as i can see on each line what is happening. The html is <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <form action=""> <div class="input-group input-group-lg m-5" style="width:auto;"> <input class="form-control text-center " type="text" placeholder="Enter Menu Name..."> </div> <!-- start clone from here --> <div id="newMenuItemLine" class="input-group mb-3"> <div class="input-group-prepend"> <span class="input-group-text" id="inputGroup-sizing-default">Menu Item</span> </div> <textarea name="newMenuItem[]" type="text" class="form-control" style="height:60px;"></textarea> <div class="input-group-text"> <div class="form-check form-check-inline mr-0"> <input name="newMenuItemVegi[]" class="form-check-input" type="checkbox" data-toggle="toggle" data-style="mr-1" data-on="Vegitarian" data-off="Not Vegi" data-onstyle="success" data-offstyle="danger" data-size="sm"> </div> <div class="form-check form-check-inline mr-0"> <input name="newMenuItemVegan[]" class="form-check-input" type="checkbox" data-toggle="toggle" data-style="mr-1" data-on="Vegan" data-off="Not Vegan" data-onstyle="success" data-offstyle="danger" data-size="sm"> </div> <div class="form-check form-check-inline mr-0"> <input name="newMenuItemGf[]" class="form-check-input" type="checkbox" data-toggle="toggle" data-style="" data-on="Gluten Free" data-off="Not GF" data-onstyle="success" data-offstyle="danger" data-size="sm"> </div> </div> </div> <!-- end clone here --> </form> <div id="newRowButton" class="btn btn-primary float-right">New Line</div> I have added the bootstrap link to make it more clear if copying into something like liveweave
  11. So i copied what you have above directly into my code and have selected one user, backed out and selected another, here are the console logs that i get. My code to show second modal $('#userDeleteConfirmationModal').on('show.bs.modal', function(event) { // Button that triggered the modal var button2 = $(event.relatedTarget) console.log(button2[0]); console.log(button2.data('userid')) console.log(event.relatedTarget) //data elements var userid = button2.data('userid') var firstname = button2.data('firstname') var lastname = button2.data('lastname') var activesheets = button2.data('activesheets').split(", ").join("<br/>") var modal = $(this) modal.find('#deleteUserConfLabel').text(firstname + ' ' + lastname) modal.find('#active-sheets-label').text('This user has the following active sheets') modal.find('#active-sheets').html(activesheets) modal.find('#staffMemberId').val(userid) }); First Try first modalhttps://adamhumbug.co.uk/user-list.php#userModal 2 <a id="callDeleteUserConf" class="btn btn-danger" data-toggle="modal" data-userid="2" data-activesheets="A new event, Chelsea's Event" href="#userDeleteConfirmationModal" data-firstname="Chelsea" data-lastname="Hockley"> 2 <a id="callDeleteUserConf" class="btn btn-danger" data-toggle="modal" data-userid="2" data-activesheets="A new event, Chelsea's Event" href="#userDeleteConfirmationModal" data-firstname="Chelsea" data-lastname="Hockley"> Second Try first modalhttps://adamhumbug.co.uk/user-list.php#userModal 8 <a id="callDeleteUserConf" class="btn btn-danger" data-toggle="modal" data-userid="8" data-activesheets="" href="#userDeleteConfirmationModal" data-firstname="First Name" data-lastname="Last Name"> 2 <a id="callDeleteUserConf" class="btn btn-danger" data-toggle="modal" data-userid="8" data-activesheets="" href="#userDeleteConfirmationModal" data-firstname="First Name" data-lastname="Last Name">
  12. <a id="callDeleteUserConf" class="btn btn-danger" data-toggle="modal" data-userid="8" data-activesheets="" href="#userDeleteConfirmationModal" data-firstname="First Name" data-lastname="Last Name"> Yes its the right thing
  13. Object [ a#callDeleteUserConf.btn.btn-danger ]
×
×
  • 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.