Jump to content

bambinou1980

Members
  • Posts

    130
  • Joined

  • Last visited

Everything posted by bambinou1980

  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,
  16. Hello, I am developing my first php script, I have a problem with the "not found" folders on the website. Let's say I the user goes here: http://mysite.com/folder1 but there are not folders there. At the moment I have this showing: Object not found!The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. With the htaccess, how can I reroute the user to let's say the index page of the website please? Thank you,
  17. Hi, Thank you for the reply. Is there a way to send something to paypal without an API key? IE: I have domainA.com with multiple shops When customer buys he may checkout to: Business1@business-paypal-address1.com or business2@business-paypal-address2.com or business3@business-paypal-address3.com a few hundreds of them. It is my understand that we can create a form with the "notify_url" hidden field, then the cart items to paypal, and GET the call back parameters, if this works that way, where is the API key needed? Thanks,
  18. Hello, I am struggling understanding exactly how the Paypal logic works. From the info I got, you need to POST an hidden field with the notify_url parameter name and set a return url. 1)My first question is, will I be able to GET multiple returned parameters on successful transaction? Will the GET parameters be passed if the transaction fails? 2)My script is about multiple shops, users will checkout and the money will go in whatever shops they are buying from, my worry is that Paypal may need and API key of some sort to send the money to an account, is it possible to send money to different shops from the same domain? 3)Something that completly confused me is this: https://developer.paypal.com/docs/classic/api/apiCredentials/ Why use an API key, username,password if you can just send payments without it Thank you,
  19. Sorry what I mean is that any scripts with an upload image folder which I install on this dedicated server have to have the upload folders set to chmod777. Right now I installed this script in a php file: <?php $processUser = posix_getpwuid(posix_geteuid()); print $processUser['name']; ?> And it shows the user as "Nobody" I am trying to understand why I must set every time my folders to CHMOD777, if I set them to CHMOD755, the uploads won't work.. How can I solve my upload problem without using CHMOD777(for security purpose) but still be able to upload my files. I just checked, this server has Suphp installed. What shall I do Next please? Thanks, Ben
  20. Hello, I would like to know how I can stop my image upload folders to be CHMOD777. What is the best way to takle this problem(step by step please). I understand this is an issue with permission on the server but how can I do it in a way that I can lower the permission safely please. What do I need to check for in my Linux server?(CENTOS 6.7 x86_64 standard). Let's say I create a php upload script now and upload it to "http://mysite.com/script", what is the next step? I am still a novice in PHP and struggle to understand how to get the technical flow of the next steps...... What to type, where to go in the server to find out the needed information to stop this problem from happening. Thank you, Ben
  21. Hi Jacques, What I am not understanding is that my form where the data is passed has <meta charset="UTF-8"> to the top, is this not enough to change the data to UTF-8 upon submission? Regarding the ISO-8859-1-encoded that you are speaking about, it should not happen if I have <meta charset="UTF-8"> at the top of the page no? Thank you,
  22. Hello, I am having a problem. Let's say I have this text: $text = "This is the price in €"; When I encode it: $encoded_text = utf8_encode($text); The output is : This is the price in The Euro sign is missing. Any idea why please? Thank you, Ben
  23. Thank you Jacques, I will have to look deeper into this and check via ssh those folders. I will also look online and try to find some tutorials about users and groups for Linux systems,how to create or delete them and give them permissions. Yes I am using sftp with FileZilla, I have always used it that way.
  24. Hi Jacques, I think the part that really confuses me is the group and users part. I am learning php at the moment, Linux is not an OS i have used before, I am still a bit lost onto what is the difference between a domain user, ftp user and script user, are they the same? Are users and groups in Linux the same as the users you create via a cpanel or are they totally different? I do not know if you have ever used a WHM panel on a dedicated server but is there a way to see a global picture of all the groups and users on the server? I am reading about Wheel groups in the WHM, are they the same as Linux groups? https://documentation.cpanel.net/display/ALD/Manage+Wheel+Group+Users Let's say I create a PHP file right now in an ftp directory, will the owner of that file be the user linked to the cpanel account? Thank you,
  25. Hi Jacques, This is a dedicated server with only 1 account and we do not share this server with anyone else. I see 777 permissions in many php scripts I download, especially for pictures upload folders, this is why I wanted to ask this question. I have pretty much never downloaded a script that do not require CHMOD 777 for picture upload. What would be the best way to allow some text to be appended to a .txt file on the server using a php script without having this .txt file CHMOD to 777, would you have a step by step on this please as I have created a php script last time and I just cannot append anything to this .txt file without chmoding it to 777 first. Let's say my ftp account user is called "user xyz", why can't my php script that was uploaded with "user xyz" cannot write to anything in that "user xzy/public_html/folder/hello.txt" location without any CHMOD777((on the .txt file), I just do not understand this security part, this does not make sense to me as "user xyz" is already the owner of this web server account and the file itself was uploaded by user xyz. In reply to your question regarding the .txt file, the sms printers work this way: 1)You append a line of text with *, ; and # symbols which are delimiters for the order items, prices and so on. 2)One order is defined by # at the start and # at the end. 3)Every 10 seconds the printer connects to a PHP file that has the username and password of the printer, if they both match, the php file serves the .txt file to the printer. 4)The printer recognize that a new order arrived by comparing the byte size of the .txt file of the last download vs the new download, if the byte size is different, the printer knows a new order is here. The order number is also being read by the printer and this number has to also be different from the last download. 5)The printer can only download 1024 bytes maximum per download, therefore if the .txt file is 1500 bytes, it will need 2 downloads to process the full order and 20 seconds in total. In the instruction of such printer, it says to use a .txt file so the byte size of the order can be calculated by the printer. When the order is fully downloaded and that no other orders have appended to the .txt file, the txt file has to be cleared. The url that is pinged by the printer is hard coded inside the printer firmware. I hope this explains a little better why we need to use a .txt file. 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.