Jump to content

Adamhumbug

Members
  • Content Count

    71
  • Joined

  • Last visited

Everything posted by Adamhumbug

  1. I have made some changes. while ($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td style='width:70%;'>".$row['money_item']."</td>"; echo "<input id='moneyId".$i."' type='hidden' name='moneyId[]' data-amount='".$row['money_value']."' value='".$row['money_id']."'>"; echo "<td class='text-center'><input id='moneyquantity".$i."' class='Qty up text-center' value='".$row['money_qty']."' name='moneyQty[]' type='text'></td>"; echo "<td><span id='moneyTotal".$i."'></span></td>"; echo "</tr>"; $i++; } <input data-amount="90.00" id="moneyId1" name="moneyId[]" type="hidden" value="1"><input data-amount="0.00" id="moneyId2" name="moneyId[]" type="hidden" value="5"><input data-amount="0.00" id="moneyId3" name="moneyId[]" type="hidden" value="6"><input data-amount="1000.00" id="moneyId4" name="moneyId[]" type="hidden" value="4"><input data-amount="150.00" id="moneyId5" name="moneyId[]" type="hidden" value="2"><input data-amount="300.00" id="moneyId6" name="moneyId[]" type="hidden" value="3"> <table> <tr class="text-center"> <th>Item</th> <th>Quantity</th> <th>Line Value</th> </tr> <tr> <td style="width:70%;">£90 Float Bag</td> <td class="text-center"><input class="Qty up text-center" id="moneyquantity1" name="moneyQty[]" type="text" value="3"></td> <td><span id="moneyTotal1">£270</span></td> </tr> <tr> <td style="width:70%;">First Aid Kit</td> <td class="text-center"><input class="Qty up text-center" id="moneyquantity2" name="moneyQty[]" type="text" value=""></td> <td><span id="moneyTotal2"></span></td> </tr> <tr> <td style="width:70%;">Waiter Pad</td> <td class="text-center"><input class="Qty up text-center" id="moneyquantity3" name="moneyQty[]" type="text" value=""></td> <td><span id="moneyTotal3"></span></td> </tr> <tr> <td style="width:70%;">£1000 Change Bag</td> <td class="text-center"><input class="Qty up text-center" id="moneyquantity4" name="moneyQty[]" type="text" value=""></td> <td><span id="moneyTotal4"></span></td> </tr> <tr> <td style="width:70%;">£150 Float Bag</td> <td class="text-center"><input class="Qty up text-center" id="moneyquantity5" name="moneyQty[]" type="text" value=""></td> <td><span id="moneyTotal5"></span></td> </tr> <tr> <td style="width:70%;">£300 Change Bag</td> <td class="text-center"><input class="Qty up text-center" id="moneyquantity6" name="moneyQty[]" type="text" value=""></td> <td><span id="moneyTotal6"></span></td> </tr> </table> var qty = document.getElementById("moneyquantity1").value; var amount = document.getElementById("moneyId1").getAttribute("data-amount"); var total ='£'+ qty * amount; $("#moneyTotal1").append(total); i have not added the handler yet to make it update live but it does what i want for one line.
  2. Sorry, i repeated myself there. I wanted to multiply the amount by the qty and show this value on the screen. This will have no impact on the values that are stored in the database but will just be used on screen to show the user the total amount.
  3. Thanks both. I added the following to my database connection and that has done the trick. mysqli_set_charset( $conn, 'utf8'); Thanks again, Kind Regards Adam
  4. I am having an issue with £ that i have in my database showing on my webpage as a triangle ?. I have my database encoded as utf8_general_ci and i declare <meta charset="UTF-8"> in my head. Is there something that i am missing here? Help is appreciated. Kind Regards Adam
  5. HI All, I am wanting to do some maths with JS on my website that is built dynamically from information held in my database. It is going to be a very simple multiplication but i am struggling to know how to write the JS to know which line to run on. The code that builds it is the following: while ($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td style='width:70%;'>".$row['money_item']."</td>"; echo "<input type='hidden' name='moneyId[]' amount='".$row['money_value']."' value='".$row['money_id']."'>"; echo "<td class='text-center'><input class='Qty up text-center' value='".$row['money_qty']."' name='moneyQty[]' type='text'></td>"; echo "<td><span id='moneyTotal'>This</span></td>"; echo "</tr>"; } and it looks like this when built: <tbody> <tr class="text-center"> <th>Item</th> <th value="0">Quantity</th> <th>Line Value</th> </tr> <tr> <td style="width:70%;">90.00 Float Bag</td> <input type="hidden" name="moneyId[]" amount="90.00" value="1"> <td class="text-center"><input class="Qty up text-center" value="100" name="moneyQty[]" type="text"></td> <td><span id="moneyTotal">This</span></td> </tr> <tr> <td style="width:70%;">1000.00 Change Bag</td> <input type="hidden" name="moneyId[]" amount="1000.00" value="4"> <td class="text-center"><input class="Qty up text-center" value="" name="moneyQty[]" type="text"></td> <td><span id="moneyTotal">This</span></td> </tr> <tr> <td style="width:70%;">150.00 Float Bag</td> <input type="hidden" name="moneyId[]" amount="150.00" value="2"> <td class="text-center"><input class="Qty up text-center" value="" name="moneyQty[]" type="text"></td> <td><span id="moneyTotal">This</span></td> </tr> <tr> <td style="width:70%;">300.00 Change Bag</td> <input type="hidden" name="moneyId[]" amount="300.00" value="3"> <td class="text-center"><input class="Qty up text-center" value="" name="moneyQty[]" type="text"></td> <td><span id="moneyTotal">This</span></td> </tr> <tr> <td style="width:70%;">First Aid Kit</td> <input type="hidden" name="moneyId[]" amount="0.00" value="5"> <td class="text-center"><input class="Qty up text-center" value="" name="moneyQty[]" type="text"></td> <td><span id="moneyTotal">This</span></td> </tr> <tr> <td style="width:70%;">Waiter Pad</td> <input type="hidden" name="moneyId[]" amount="0.00" value="6"> <td class="text-center"><input class="Qty up text-center" value="" name="moneyQty[]" type="text"></td> <td><span id="moneyTotal">This</span></td> </tr> </tbody> I am wanting to multiply the amount by the amount (which in the first row is 90.00) by the qty which is an input box. I can work out how to do the standard maths if there was only one row but i dont know how to get this to run on each line and update the money total. Help as always is appreciated. Kind Regards Adam
  6. Thanks so much for your help. I will for sure take your suggestions on board and have a look at how i am doing things. Thanks again Barand, i will take yours on board also. How would i go about this without having two sets of code? Would i have another document with an include?
  7. I have just realised, that i dont have job id in that query. I need to only select items that have the job id that has been set. In the current case, i only have one job id in the table but i dont use this variable in the second query $jid = $_SESSION[current_job_id]
  8. Just as an fyi, when i run this in mysql this is what i see. I changed the ? in the query to be 1.
  9. Table A - ssm_menu This is where the menu name and price are defined menu_id menu_name menu_price 1 menu 1 22.50 2 menu 2 51.50 Table B - ssm_menu_connection This is where the menu items are connected to a menu menu_id menu_item_id surrogate_id 1 1 1 1 4 2 2 1 3 Table C - ssm_menu_item This is where the individual items for each menu are defined and given a catagory menu_item_id menu_item_name menu_item_catagory 1 soup starter 2 pudding desert Table D - ssm_menu_order When the menu items are given a qantity, this is the table that they go into for later use. job_id menu_id menu_item_id menu_item_qty surrogate_id 1 1 1 100 1 1 1 2 100 2 This is the basic layout of all of the tables that are used in the query. If the user selects menu one and submits the form with quantities for some of the items, when the page reloads i want it to display all items in the menu that the user select but also show the quantities that they submitted. This will mean that some items have quantities and some do not. Either way all menu items for that menu should be shown. I hope this helps. Kind Regards
  10. Hi all, I am pulling info from my database but for some reason the results are being populated twice. The code i have is below: $jid = $_SESSION['current_job_id']; $sql = "SELECT * FROM ssm_menu_order where job_id = $jid"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result)>0){ $sql = "SELECT menu_name, menu_price, menu_item_name, menu_item_catagory, b.menu_item_id, a.menu_id, d.job_id, d.menu_item_qty FROM ssm_menu a INNER JOIN ssm_menu_connection b on a.menu_id = b.menu_id INNER JOIN ssm_menu_items c on b.menu_item_id = c.menu_item_id left join ssm_menu_order d on c.menu_item_id = d.menu_item_id WHERE d.menu_id = ? ORDER BY (CASE c.menu_item_catagory WHEN 'Starter' THEN 1 WHEN 'Main' THEN 2 WHEN 'Dessert' THEN 3 ELSE 100 END) ASC, c.menu_item_name ASC"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $_GET['q']); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($mname, $mprice, $mitname, $mitcat, $miid, $mid, $jid, $qty); echo"<form action='actions/update-menu-action.php' method='post'>"; echo "<button type='submit' name='select_menu_update_button' class='btn btn-primary float-right mb-2'>Update</button>"; echo "<table class='table table-striped table-hover table-bordered mt-3'>"; $first = true; while($stmt->fetch()){ if($first) { echo "<tr>"; echo "<th class='text-center' colspan='5'><div>".$mname." - £".$mprice."</div></th>"; echo "</tr>"; echo "<tr class='text-center'><th>Course</th><th>Dish</th><th>Notes</th><th>Quantity</th></tr>"; $first = NULL; } echo "<tr>"; echo "<td class=''>" . $mitcat . "</td>"; echo "<td class=''>" . $mitname . "</td>"; echo "<td><input type='text' /></td>"; echo "<input type='hidden' name='menuItemId[]' value='".$miid."'>"; echo "<input name='menuId' type='hidden' value='".$mid."'/>"; echo "<td><input class='text-center' name='menuItemQty[]' value='".$qty."' /></td>"; echo "</tr>"; } echo "</table>"; echo "</form>"; $stmt->close(); } else { $sql = "SELECT menu_name, menu_price, menu_item_name, menu_item_catagory, b.menu_item_id, a.menu_id FROM ssm_menu a INNER JOIN ssm_menu_connection b on a.menu_id = b.menu_id INNER JOIN ssm_menu_items c on b.menu_item_id = c.menu_item_id WHERE a.menu_id = ? ORDER BY (CASE c.menu_item_catagory WHEN 'Starter' THEN 1 WHEN 'Main' THEN 2 WHEN 'Dessert' THEN 3 ELSE 100 END) ASC, c.menu_item_name ASC"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $_GET['q']); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($mname, $mprice, $mitname, $mitcat, $miid, $mid); echo"<form action='actions/submit-menu-action.php' method='post'>"; echo "<button type='submit' name='select_menu_submit_button' class='btn btn-primary float-right mb-2'>Submit</button>"; echo "<table class='table table-striped table-hover table-bordered mt-3'>"; $first = true; while($stmt->fetch()){ if($first) { echo "<tr>"; echo "<th class='text-center' colspan='5'><div>".$mname." - £".$mprice."</div></th>"; echo "</tr>"; echo "<tr class='text-center'><th>Course</th><th>Dish</th><th>Notes</th><th>Quantity</th></tr>"; $first = NULL; } echo "<tr>"; echo "<td class=''>" . $mitcat . "</td>"; echo "<td class=''>" . $mitname . "</td>"; echo "<td><input type='text' /></td>"; echo "<input type='hidden' name='menuItemId[]' value='".$miid."'>"; echo "<input name='menuId' type='hidden' value='".$mid."'/>"; echo "<td><input name='menuItemQty[]' /></td>"; echo "</tr>"; } echo "</table>"; echo "</form>"; $stmt->close(); } For some reason, the reasults are being echo'd twice.
  11. Ok tested and that did the trick. Thanks for all of your help. I didnt even know that was a thing. Kind Regards Adam
  12. Ok, so if i follow you correctly, i have run the follwing on my table ALTER TABLE `ssm_equipment_order` ADD UNIQUE( `job_id`, `equipment_id`); Is this what you were referring to?
  13. Hi Barand, Thanks for this - i have tried this in my code and have found that when i add a value to a new equipment ID, the insert works but at the same time, everything else in the table gets duplicated. When i try and update an existing value, the value gets added rather than updating the original and everythig else is duplicated The reason i had the where in orginally was due to the update that i had written which worked perfectly that i tried to modify and combine with the second set of code below which was the origional submission $stmt = $conn->prepare("UPDATE ssm_equipment_order SET equipment_quantity = ? WHERE job_id = ? and equipment_id = ?"); $stmt = $conn->prepare("INSERT INTO ssm_equipment_order (equipment_quantity, job_id, equipment_id) VALUES (?,?,?) "); Currently, using the code that you have provided and attempts that i have had myself, everytime i click the update button, the whole table content gets duplicated. Kind Regards ADam
  14. Thanks for the quick reply, neither the job_id or the equipment_id will be unique in that table. The combination will be unique, there will only ever be one row with the job_id 10 and the equipment_id 10
  15. Now that i have selected it and got it out of the database, i have written an update SQL. However i now realise i need it to insert if there is nothing to update. Good has shown me that i need to run an ON DUPLICATE KEY UPDATE but it fails. <?php if ($_SERVER['REQUEST_METHOD']=='POST') { $jobId = $_SESSION['current_job_id']; $qty = $_POST['equipmentQty']; // prepare insert and update query $stmt = $conn->prepare("INSERT INTO ssm_equipment_order (equipment_quantity, job_id, equipment_id) VALUES (?,?,?) ON DUPLICATE KEY UPDATE ssm_equipment_order SET equipment_quantity = ? WHERE job_id = ? and equipment_id = ?"); foreach ($_POST['equipmentId'] as $k => $eid) { if ($qty[$k] > 0) { $stmt->bind_param("sss", $qty[$k], $jobId, $eid); $stmt->execute(); } } } header("location: ../order-equipment.php"); Is there something that i am missing here?
  16. Ahhhh So something like this SELECT a.equipment_id, equipment_name, equipment_category, b.equipment_quantity, b.job_id FROM ssm_equipment a LEFT JOIN ssm_equipment_order b ON a.equipment_id = b.equipment_id and b.job_id = 24 That looks like it would work.
  17. I have moved this question to here Thanks for all of your help so far
  18. I am creating a table that creates many rows based on what is in the equipment table. There is a second table that has information pertaining to an order that has already been made. equipment table is as follows: equipment_id equipment_name 1 Book 2 Dog 3 cat 4 hat equipment order table is as follows: job_id equipment_id equipment_quantity 10 1 100 10 3 100 There are 20 things in the equipment table. When the page loads, i would like it to show all of the items from the equipment table but i would like the rows where there is a quantity defined in the equipment_order table to be populated. So i should see Eauipment Quantity Book 100 Dog cat 100 hat The sql that i have used is this SELECT a.equipment_id, equipment_name, equipment_category, b.equipment_quantity FROM ssm_equipment a LEFT JOIN ssm_equipment_order b ON a.equipment_id = b.equipment_id Quite rightly this select anything with a quantity regardless of whether it relates to the current job or not. I have a variable $current_job_id that needs to be used to only get the values for the current job I tried the following SELECT a.equipment_id, equipment_name, equipment_category, b.equipment_quantity FROM ssm_equipment a LEFT JOIN ssm_equipment_order b ON a.equipment_id = b.equipment_id WHERE $current_job_id = 10 but this only get the rows where the ids match. I tried moving the WHERE clause but i cant seem to figure this out with out getting many errors. I have also tried the followin to no avail. SELECT a.equipment_id, equipment_name, equipment_category, b.equipment_quantity, b.job_id FROM ssm_equipment a LEFT JOIN ssm_equipment_order b ON a.equipment_id = b.equipment_id where b.job_id = '24' or b.job_id='NULL' The above just shows row with 24 I have talked about this in another thread but as this is very different to the origional question, i have moved it. Origional questions is below
  19. I have been using the following code to move the tr to the top if the input is changed. $('#equipmentTable input.eqQty').focusout(function() { var row = $(this).closest('tr'); if ($(this).hasClass('up')) row.insertBefore( row.parent().find('tr:first-child') ) .find('label').html('move to bottom'); else row.next().after(row); }); I have actually found it really annoying and have decided to look at another approach. I would actually like it to move to the top of the table but appear underneath all of the other rows that have something in the input box. This will mean that the first changed textbox will be at the top, second will be second and so on. Ideally it wont move if you change it. This is well above my javascript knowledge so would appreciate some assistance. I have been playing with the insertBefore and making it insertAfter but have been unable to get it to do what i wanted. Thanks in advance, Kind Regards Adam
  20. So, thank you all for your support here, i am now able to submit this large form successfully. The submission code is as follows. <?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_name'])){ header("location: index.php"); } include '../_includes/dbconn.php'; if ($_SERVER['REQUEST_METHOD']=='POST') { $jobId = $_SESSION['current_job_id']; $qty = $_POST['equipmentQty']; // prepare insert query $stmt = $conn->prepare("INSERT INTO ssm_equipment_order (job_id, equipment_id, equipment_quantity) VALUES (?,?,?) "); foreach ($_POST['equipmentId'] as $k => $eid) { if ($qty[$k] > 0) { // $data = [$jobId, $eid, $qty[$k] ] ; $stmt->bind_param("sss", $jobId, $eid, $qty[$k]); $stmt->execute(); } } } header("location: ../order-equipment.php"); My issue now is that when this page loads, it needs to get the information out of the database that builds the large form and fill the inputs with the quantities that were submitted before. I have written the following: <?php include '_includes/dbconn.php'; $current_job_id = $_SESSION['current_job_id']; $sql = "SELECT * FROM ssm_equipment_order where job_id = $current_job_id"; if ($result = mysqli_query($conn, $sql)){ if(mysqli_num_rows($result)>0){ $sql = "SELECT * FROM ssm_equipment"; if ($result = mysqli_query($conn, $sql)){ if(mysqli_num_rows($result)>0){ echo "<form method='post' action='actions/submit-equipment-order-action.php' id='equipmentOrderForm'>"; echo "<div class='input-group mt-3 mb-3'>"; echo "<div class='input-group-prepend'>"; echo "<span class='input-group-text'>Search (alt/option+s)</span>"; echo "</div>"; echo "<input id='equipmentTableSearch' onkeyup='searchEquipmentTable()' type='text' class='form-control' placeholder='Plates...Soup Spoon...Red Wine Glass...'>"; echo "<button type='submit' name='equipment_submit_button' class='btn btn-primary'>Submit</button'>"; echo "</div>"; echo "<table id='equipmentTable' class='mt-3 table table-striped table-hover table-bordered'>"; echo "<thead>"; echo "<tr class='text-center'><th>Equipment</th><th>Quantity</th></tr>"; echo "</thead>"; echo "<tbody>"; $current_job_id = $_SESSION['current_job_id']; $sql2 = "SELECT * FROM ssm_equipment_order WHERE job_id = $current_job_id"; $result2 = mysqli_query($conn, $sql2); while ($row2 = mysqli_fetch_array($result2)){ echo "XX "; } while ($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td style='width:70%;'>".$row['equipment_name']."</td>"; echo "<input type='hidden' name='equipmentId[]' value='".$row['equipment_id']."'>"; echo "<td class='text-center'><input name='equipmentQty[]' class='eqQty text-center up' type='text'></td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "</form>"; } } }else{ //the above is doing an if there is an equipment order already $sql = "SELECT * FROM ssm_equipment"; if ($result = mysqli_query($conn, $sql)){ if(mysqli_num_rows($result)>0){ echo "<form method='post' action='actions/submit-equipment-order-action.php' id='equipmentOrderForm'>"; echo "<div class='input-group mt-3 mb-3'>"; echo "<div class='input-group-prepend'>"; echo "<span class='input-group-text'>Search (alt/option+s)</span>"; echo "</div>"; echo "<input id='equipmentTableSearch' onkeyup='searchEquipmentTable()' type='text' class='form-control' placeholder='Plates...Soup Spoon...Red Wine Glass...'>"; echo "<button type='submit' name='equipment_submit_button' class='btn btn-primary'>Submit</button'>"; echo "</div>"; echo "<table id='equipmentTable' class='mt-3 table table-striped table-hover table-bordered'>"; echo "<thead>"; echo "<tr class='text-center'><th>Equipment</th><th>Quantity</th></tr>"; echo "</thead>"; echo "<tbody>"; while ($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td style='width:70%;'>".$row['equipment_name']."</td>"; echo "<input type='hidden' name='equipmentId[]' value='".$row['equipment_id']."'>"; echo "<td class='text-center'><input name='equipmentQty[]' class='eqQty text-center up' type='text'></td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "</form>"; } } } } ?> The following line is successfully showing the correct number of results, for how many items have a qty but i do not know how to use this information to populate the correct text boxes in the table. while ($row2 = mysqli_fetch_array($result2)){ echo "XX "; }
  21. Hi Barand, Thanks for the suggestion. Is this in place of what i have to currently create my form. <?php include '_includes/dbconn.php'; $sql = "SELECT * FROM ssm_equipment"; if ($result = mysqli_query($conn, $sql)){ if(mysqli_num_rows($result)>0){ echo "<form method='post' action='actions/submit-equipment-order-action.php' id='equipmentOrderForm'>"; echo "<div class='input-group mt-3 mb-3'>"; echo "<div class='input-group-prepend'>"; echo "<span class='input-group-text'>Search (alt/option+s)</span>"; echo "</div>"; echo "<input id='equipmentTableSearch' onkeyup='searchEquipmentTable()' type='text' class='form-control' placeholder='Plates...Soup Spoon...Red Wine Glass...'>"; echo "<button type='submit' name='equipment_submit_button' class='btn btn-primary'>Submit</button'>"; echo "</div>"; echo "<table id='equipmentTable' class='mt-3 table table-striped table-hover table-bordered'>"; echo "<thead>"; echo "<tr class='text-center'><th>Equipment</th><th>Quantity</th></tr>"; echo "</thead>"; echo "<tbody>"; while ($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td style='width:70%;'>".$row['equipment_name']."</td>"; echo "<input type='hidden' name='equipmentId[]' value='".$row['equipment_id']."'>"; echo "<td class='text-center'><input name='equipmentQty[]' class='eqQty text-center up' type='text'></td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "</form>"; } } ?>
  22. So i changed the HTML to be the following to use data[ ] <tr> <td style="width:70%;">Item 1</td> <input type="hidden" name="data[equipmentId]" value="1"> <td class="text-center"> <input name="data[equipmentQty]" class="eqQty text-center up" type="text"> </td> </tr> <tr> <td style="width:70%;">Item 2</td> <input type="hidden" name="data[equipmentId]" value="2"> <td class="text-center"> <input name="data[equipmentQty]" class="eqQty text-center up" type="text"> </td> </tr> And the php $_POST['data']; print_r($_POST['data']); This gives me the following regardless of how many rows i type a quantity into, also, it is not putting the quantity into the array. Also, equipment id 22 is the last item in the table. Array ( [equipmentId] => 22 [equipmentQty] => ) A bit lost
  23. Here is the html <form id="equipmentOrderForm" action="actions/submit-equipment-order-action.php" method="post"> <div class="input-group mt-3 mb-3"> <div class="input-group-prepend"><span class="input-group-text">Search (alt/option+s)</span></div> <input id="equipmentTableSearch" class="form-control" type="text" placeholder="Plates...Soup Spoon...Red Wine Glass..." /><button class="btn btn-primary" name="equipment_submit_button" type="submit">Submit</button></div> <table id="equipmentTable" class="mt-3 table table-striped table-hover table-bordered"> <thead> <tr class="text-center"> <th>Equipment</th> <th>Quantity</th> </tr> </thead> <tbody> <tr> <td style="width:70%;">Item 1</td> <input type="hidden" name="equipmentId[]" value="1"> <td class="text-center"> <input name="equipmentQty[]" class="eqQty text-center up" type="text"> </td> </tr> <tr> <td style="width:70%;">Item 2</td> <input type="hidden" name="equipmentId[]" value="2"> <td class="text-center"> <input name="equipmentQty[]" class="eqQty text-center up" type="text"> </td> </tr> </tbody> </table> </form> Here is the JS function searchEquipmentTable() { // Declare variables var input, filter, table, tr, td, i, txtValue; input = document.getElementById("equipmentTableSearch"); filter = input.value.toUpperCase(); table = document.getElementById("equipmentTable"); tr = table.getElementsByTagName("tr"); // Loop through all table rows, and hide those who don't match the search query for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }
  24. Hi, Thanks for this. So i have made some changes and have used serialise. I have three things to import per line, the first is an ID and should be the same on every line. The second is the value of a hidden input which will be different per line. The third is the value of a text box which may be different on each line. I do not want to include rows where the number in the input is zero or blank. I have this $jobId = $_SESSION['current_job_id']; $equipmentId = serialize($_POST['equipmentId']); $equipmentQty = serialize($_POST['equipmentQty']); $sql = "INSERT INTO ssm_equipment_order (job_id, equipment_id, equipment_quantity) VALUES ('$jobId', '$equipmentId', '$equipmentQty')"; but when printing $sql i get the following INSERT INTO ssm_equipment_order (job_id, equipment_id, equipment_quantity) VALUES ('25', 'a:22:{i:0;s:1:"2";i:1;s:1:"1";i:2;s:1:"3";i:3;s:1:"4";i:4;s:1:"5";i:5;s:1:"6";i:6;s:1:"7";i:7;s:1:"8";i:8;s:1:"9";i:9;s:2:"10";i:10;s:2:"11";i:11;s:2:"12";i:12;s:2:"13";i:13;s:2:"14";i:14;s:2:"15";i:15;s:2:"16";i:16;s:2:"17";i:17;s:2:"18";i:18;s:2:"19";i:19;s:2:"20";i:20;s:2:"21";i:21;s:2:"22";}', 'a:22:{i:0;s:2:"10";i:1;s:2:"10";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";i:6;s:0:"";i:7;s:0:"";i:8;s:0:"";i:9;s:0:"";i:10;s:0:"";i:11;s:0:"";i:12;s:0:"";i:13;s:0:"";i:14;s:0:"";i:15;s:0:"";i:16;s:0:"";i:17;s:0:"";i:18;s:0:"";i:19;s:0:"";i:20;s:0:"";i:21;s:0:"";}') So i feel like i am on the right lines and will keep looking. One thing i am not sure on is how to only include in the array rows where the equipmentQty is not 0 or blank.
×
×
  • 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.