Jump to content

bambinou1980

Members
  • Content Count

    130
  • Joined

  • Last visited

Community Reputation

0 Neutral

About bambinou1980

  • Rank
    Advanced Member
  1. Mac Gyver, I have no words for your comments and will have to change my username as I don't like when someone is following me on the internet. "between the forums that i know you post on, you have several hundred posts"<---- NSA?
  2. Hello, I am not understanding why, I do not get an array output there, is there a problem with my php code? <?php $query = "SELECT o.orders_id, date_format(o.due_date, '%d/%m/%Y') as day, o.customer_paid, p.product_price, p.product_quantity, p.product_price * p.product_quantity AS totals, p.orders_orders_id FROM orders AS o LEFT JOIN products_ordered AS p ON o.orders_id = p.orders_orders_id WHERE YEAR(o.due_date) = YEAR(CURDATE()) AND MONTH(o.due_date) = MONTH(CURDATE()) WHERE o.customer_paid = 'PAID' GROUP BY o.orders_id"; if (mysqli_connect_errno()) die('Could not connect: ' . mysql_error()); $return_arr = array(); if ($result = mysqli_query($connection, $query)) { while ($row = mysqli_fetch_assoc($result)) { $row_array['orders_id'] = $row['orders_id']; $row_array['product_price'] = $row['product_price']; array_push($return_arr, $row_array); } } mysqli_close($connection); echo json_encode($return_arr); ?> Thanks
  3. Ok Worked it out: <?php while ($row = mysqli_fetch_array($result1, MYSQLI_ASSOC)) { $product_name = $row["product_name"]; $product_quantity = $row["product_quantity"]; $product_price = $row["product_price"]; $product_vat = $row["product_vat"]; ?><tr><td><div class="text-center"><h4><?php echo $product_name; ?></h4></div></td><td><div class="text-center"><h4><?php echo $product_quantity; ?></h4></div></td><td><div class="text-center"><h4><?php echo $product_price; ?></h4></div></td><td><div class="text-center"><h4><?php echo $product_vat; ?></h4></div></td></tr><?php } ?>
  4. Hello, I am trying to construct my first while loop and struggle a bit. I have a table with 4 columns, all I am trying to do is passing the product name, qty, price and vat in each column from the same table but cannot work out how to use only 1 loop rather than 4 because the html is on the way.... Any idea how I could compress the lot to make it only in 1 loop please? <?php $query1 = "SELECTo.orders_id,p.product_name,p.idFROM orders AS oLEFT JOIN products_ordered AS p ON o.orders_id = p.orders_orders_id WHERE o.orders_id = {$order_id}ORDER BY p.id DESC"; $result1 = mysqli_query($connection, $query1); if($result1 && mysqli_affected_rows($connection) < 1) { // Failure // $message = "Subject update failed"; die("Database query 1 failed. " . mysqli_error($connection));}?> <?php $query2 = "SELECTo.orders_id,p.product_quantity,p.idFROM orders AS oLEFT JOIN products_ordered AS p ON o.orders_id = p.orders_orders_id WHERE o.orders_id = {$order_id}ORDER BY p.id DESC"; $result2 = mysqli_query($connection, $query2); if($result2 && mysqli_affected_rows($connection) < 1) { // Failure // $message = "Subject update failed"; die("Database query 2 failed. " . mysqli_error($connection));}?> <?php $query3 = "SELECTo.orders_id,p.product_price,p.idFROM orders AS oLEFT JOIN products_ordered AS p ON o.orders_id = p.orders_orders_id WHERE o.orders_id = {$order_id}ORDER BY p.id DESC"; $result3 = mysqli_query($connection, $query3); if($result3 && mysqli_affected_rows($connection) < 1) { // Failure // $message = "Subject update failed"; die("Database query 3 failed. " . mysqli_error($connection));}?> <?php $query4 = "SELECTo.orders_id,p.product_vat,p.idFROM orders AS oLEFT JOIN products_ordered AS p ON o.orders_id = p.orders_orders_id WHERE o.orders_id = {$order_id}ORDER BY p.id DESC"; $result4 = mysqli_query($connection, $query4); if($result4 && mysqli_affected_rows($connection) < 1) { // Failure // $message = "Subject update failed"; die("Database query 4 failed. " . mysqli_error($connection));}?> <!-- / end client details section --> <table class="table table-bordered"> <thead> <tr> <th> <h4 class="text-center">Products Ordered</h4> </th> <th> <h4 class="text-center">Qty</h4> </th> <th> <h4 class="text-center">Products Prices</h4> </th> <th> <h4 class="text-center">V.A.T</h4> </th> </tr> </thead> <tbody> <tr> <td><div class="text-center"><h4> <?php while ($row = mysqli_fetch_array($result1, MYSQLI_ASSOC)) { $product_name = $row["product_name"]; echo $product_name . '<br>';} ?> </h4></div></td> <td><div class="text-center"><h4> <?php while ($row = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { $product_quantity = $row["product_quantity"]; echo $product_quantity . '<br>';} ?> </h4></div></td> <td><div class="text-center"><h4> <?php while ($row = mysqli_fetch_array($result3, MYSQLI_ASSOC)) { $product_price = $row["product_price"]; echo "€" .$product_price . '<br>';} ?> </h4></div></td> <td><div class="text-center"><h4> <?php while ($row = mysqli_fetch_array($result4, MYSQLI_ASSOC)) { $product_vat = $row["product_vat"]; echo $product_vat . '%<br>';} ?> </h4></div></td> </tr> </tbody> </table>
  5. Hi Mac_gyver. Ok let me explain further. My problem is those 2 input fields not changing their values according to the loop data() values: <input type="text" name="products_id[]" class="id1"/> <input type="text" name="vat[]" class="vat1"/>
  6. Yes this is exactly what I am experiencing "all the select/option menus to the same set of prices, and resetting already selected prices". I can work out the arrays in PHP and submit the data in a loop but with Javascript I am not understanding how to get the same effect. Specifically this part: $(this).closest('.form-group').find('.form-control.prices1').html(options); How to get all the ids to increment in number(if this is the answer to the problem). I would have preferred something like in PHP with prices[]. Kind of lost to be honest...
  7. Hello, I am having a problem with a php loop in which I just cannot get the data product to be shown when I add a new form element(identical). So imagine a form with an "add" and "delete" button, when I click "add" the dropdown button with "product name" is duplicated". My goal is to have the user adding multiple of those drop down buttons which when select cause different prices to be loaded. At the moment this works great for the first field but as soon as I add more than one, the price vat and product id are are loaded but based on the first dropdown each time. There is something in my javascript code that is not telling the browser to notice the incremental changes when we add the new buttons, any idea please? The product name and prices are changing right not but not the vat and product id. Here is the php: <!--Product 1--> <div id="element1" class="field"> <div class="form-inline well"> <label for="product1">Choose Product*</label> <div class="form-group" id="totals"> <select name="name[]" class="form-control products1"> <option>Select a Product</option> <?php $query_product1 = "SELECT * FROM products ORDER BY name desc"; $result_product1 = mysqli_query($connection, $query_product1) or die(mysqli_error()); while ($row_product1 = mysqli_fetch_array($result_product1)) { $product1_id = $row_product1['products_id']; $product1_name = $row_product1['name']; $product1_price1 = $row_product1['price1']; $product1_price2 = $row_product1['price2']; $product1_price3 = $row_product1['price3']; $product1_vat = $row_product1['vat']; ?> <option value="<?php echo $product1_name; ?>" data-product1_id="<?php echo $product1_id; ?>" data-product1_vat="<?php echo $product1_vat; ?>" data-product1_price1="<?php echo $product1_price1; ?>" data-product1_price2="<?php if ($product1_price2 != 0.00) { echo $product1_price2; } ?>" data-product1_price3="<?php if ($product1_price3 != 0.00) { echo $product1_price3; } ?>"><?php echo $product1_name; ?></option><?php } ?> </select> <input type="text" name="products_id[]" class="id1"/> <input type="text" name="vat[]" class="vat1"/> <select name="price[]" class="form-control prices1"> <option>Select Price</option> </select> <label for="product1_id">Qty</label> <input name="quantity[]" type="number" class="form-control quantity1" maxlength="8" size="4" required> <label for="total_id">Total Cost(€)</label> <input name="total1" type="text" class="form-control total1" value="0" maxlength="8" size="4" required> <button type="button" class="btn btn-warning">Calculate</button> </div> </div> </div> <!--Product 1--> JS $(function product1() { $('.form-control.products1').change(function () { var selected = $('option:selected', this); var options = '<option>Select Price</option>'; for (var i = 1; i <= 3; i++) { options += '<option>' + selected.data('product1_price' + i) + '</option>'; } $('.form-control.prices1').html(options); $(this).closest('.form-group').find('.id1').val(selected.data('product1_id')); $(this).closest('.form-group').find('.vat1').val(selected.data('product1_vat')); }); }); Thanks and Happy Xmas!
  8. Hello, I have a quick question please. I am trying to use Ajax for the first time. My form has a delete button as: <a class=\"btn btn-danger delete-button\" id=\"<?php echo $id; ?>\" role=\"button\">Delete</a> When I initiate my ajax call: <script type="text/javascript"> $(function() { $(".delete-button").click(function(){ var element = $(this); var del_id = element.attr("id"); var info = 'id=' + del_id; if(confirm("Are you sure you want to delete this?")) { $.ajax({ type: "GET", url: "delete-record.php", data: info, success: function(){ } }); $(this).parents(".show").animate({ backgroundColor: "#003" }, "slow") .animate({ opacity: "hide" }, "slow"); } return false; }); }); </script> I am getting a dirty url like this in the chrome XHR console: XHR finished loading: GET "http:/websitename.com/admin/crud/payments/delete-record.php?id=%3C?php%20echo%20?%3E" Any idea how to remedy to this please? I tried urlencode($id); but it did not work. Thank you, Ben
  9. yes, you are exactly pointing to what i just said, " the guys there have answered everything, so now we can move forward.... ". I never said it matters where I am getting help from, I was pointing to the other forum just to say that the problem has been resolved and that we could all move on.
  10. Anyway, we have found codingforums.com and the guys there have answered everything, so now we can move forward.... Thank you for your time.
  11. This means that every single guy who ask a question about coding(for guidance) because they are not really sure about the best solution to adopt should actually never post in forum because there is a PHP manual out there......How stupid I am...really sorry. I could not have worked this one by myself, thanks again mate, you are the best.........
  12. Perhaps because I am trying to gain a bit more time by asking someone who already knows the function I am looking for? Thank you.
  13. Hello, I am on a shared server and currently developing an app where the admin can upload pdf to a folder. My first problem is that the upload won't happen if this folder is not CHMOD777. But because it is a shared server I am quiet limited with what I can do. My second problem is that I would prefer to have the upload folder below the root level, what can I do for this to happen code wise please? Shall I just treat it as as a normal upload? Thank you, Ben
  14. Thank you for your reply. No the reason I was asking is because frameworks have a nice little routing script that do not allow people with the wrong access to go on a url. I have coded the app with permission on the landing pages yes but was wondering how do framework stop people typing urls (to pass parameters). Thank you,
  15. Thank you for the documentation but unfortunately I am getting lost into it... How would you simply tell the whole public_html folder that if there is a not found folder or file, redirect the user to the website root please? I found this code online, would this be ok: RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/clients/$1/$2 !-f RewriteCond %{DOCUMENT_ROOT}/clients/$1/$2 !-d RewriteRule ^clients/([^/]+)/(.*)$ $2 [L] Thank you,
×
×
  • 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.