clear dot Jquery and get data for sum data

I have script JQuery, and I must to explain if User input number, can separator with dot. BUt, if i mus to Calculation data but not function.

the below in the form input

<input style="text-align: center;" class="amount"    type="text" name='pembelanjaan'  id="pembelanjaan"  size="30" >
                

and this script for separator dot

    var rupiah = document.getElementById('pembelanjaan');
    rupiah.addEventListener('keyup', function(e){
        // tambahkan 'Rp.' pada saat form di ketik
        // gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka
        rupiah.value = formatRupiah(this.value, 'Rp. ');
    });

    /* Fungsi formatRupiah */
    function formatRupiah(angka, prefix){
        var number_string = angka.replace(/[^,d]/g, '').toString(),
        split           = number_string.split(','),
        sisa            = split[0].length % 3,
        rupiah          = split[0].substr(0, sisa),
        ribuan          = split[0].substr(sisa).match(/d{3}/gi);

        // tambahkan titik jika yang di input sudah menjadi angka ribuan
        if(ribuan){
            separator = sisa ? '.' : '';
            rupiah += separator + ribuan.join('.');
        }

        rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
        return prefix == undefined ? rupiah : (rupiah ? '' + rupiah : '');
    }

this JQuery for Calculation, and I Have get the input (without dot) to calculation with math.trunch

 $(document).ready(function(){
      $("#pembelanjaan").keyup(function(){
        var angka1  = parseInt($("#pembelanjaan").val());
        var sum2 = angka1.toString().replace(/./g, '');
        // var angka2  = parseInt($("#addPoint").val());
        var hasil = Math.trunc(sum2 / 25000)*2;
        $("#addPoint").val(hasil);
        var angka2  = parseInt($("#point").val());
        var hasil = (Math.trunc(angka1 / 25000)*2)+angka2;
        $("#totalpoin").val(hasil);
           });
    });
    

PHP echo multidimensional array next to each other instead underneath each other

Here is my problem.
I have created two bunny’s with character and want to display them, als with PHP.

For the two bunny’s I created a multidimensional array:

$bunnys = array(
              array( //$bunny
                  array(' ', ' ', '(', ')', ' ', '(', ')', ' ', ' '), //$row en in de array is $piece
                  array(' ', ' ', '(', 'o', '.', 'o', ')', ' ', ' '),
                  array(''', '(', '"', ')', ' ', '(', '"', ')', '''),
              ),
              array(
                  array(' ', ' ', '(', ')', ' ', '(', ')', ' ', ' '),
                  array(' ', ' ', '(', '>', '.', '<', ')', ' ', ' '),
                  array(''', '(', '"', ')', ' ', '(', '"', ')', '''),
              ),
);

Then I want to echo the bunny’s using the foreach loop:

echo "<pre>";
  foreach($bunnys as $bunny)
    {foreach ($bunny as $row)
      {foreach ($row as $piece) 
      echo "$piece";   
      echo "<br>";
      }
    }
echo "</pre>";

Actual result
The problem is, is that the bunny’s are standing underneath eachother, like this:

() ()
(o.o)
‘(“) (“)’

() ()
(>.<)
‘(“) (“)’

Desired result
But what I want, is that the bunny’s standing next to each other, like this:

() () () ()
(o.o) (>.<)
‘(“) (“)”(“) (“)’

I already tried to delete the echo "<br>";, but then the result is that there are six lines.

Anybody havind an idea what I am doing wrong?

Title must be at least 15 characters

test Introduce the problem and expand on what you put in the title. Minimum 20 charact
Describe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 characters.Describe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 charactersDescribe what you tried, what you expected to happen, and what actually resulted. Minimum 20 characters

Get unique values from a column in a CSV and convert to JSON [closed]

Hopefully, someone here can help with this issue as I am a bit of a amateur with certain bits of PHP

I have a CSV file on a server that has dates in the second column but they are in slightly differing formats and I need to get all of the unique dates and have them as a JSON output in the format below. This needs to be a PHP-based solution. I have tried using json_encode but i can’t seem to get this to work as the date formats are different and I am unsure how to get all unique dates and also how to then reformat them before including them in a JSON file.

I have tried using file_get_contents to get the file which seems to work fine. I am then stuck on how to iterate through column b and convert the dates. When i run an ajax request to get the json file i do not get any response.

{
"result": [
    "2023-10-30T00:00:00",
    "2023-10-27T00:00:00",
    "2023-10-26T00:00:00",
    "2023-10-25T00:00:00",
    "2023-10-24T00:00:00",
    "2023-10-23T00:00:00",
    "2023-10-20T00:00:00",
    "2023-10-19T00:00:00",
    "2023-10-18T00:00:00",
    "2023-10-17T00:00:00",
    "2023-10-16T00:00:00",
    "2023-10-13T00:00:00"
]

}

Here is an example of the CSV data:

ID,TradeDate,Value
1,5/31/2023 12:00:00 AM,10
2,5/31/2023 12:00:00 AM,12
3,5/31/2023 12:00:00 AM,12
4,5/31/2023 12:00:00 AM,14
5,06/01/2023 00:00,13
6,06/01/2023 00:00,15
7,06/01/2023 00:00,14
8,06/01/2023 00:00,17
9,06/01/2023 00:00,19
10,06/01/2023 00:00,18
11,06/01/2023 00:00,20
12,06/01/2023 00:00,19
13,06/01/2023 00:00,21
14,06/02/2023 00:00,20
15,06/02/2023 00:00,22
16,06/02/2023 00:00,25
17,06/02/2023 00:00,24
18,06/05/2023 00:00,31
19,06/05/2023 00:00,43

Let me know if more information is required

Integrate Angular 16 in PHP 5

I have a fully working Angular App, which has to be included in a PHP 5 working APP under Debian 7 Server.

My question is how can i do that?

the PHP app runs under example.com
the idea is to have the angular app running under example.com/angularApp

Thanks

AJAX post data is not received in PHP

I’ve recently started learning PHP from the very basics. After following some tutorials I’m trying to learn something and here I’m facing a problem and after visiting different URLs for similar issues but couldn’t solve mine.

I have a page where user enters data in form and that data is added in a grid (table) by using Add button. On Save button the table data is sent to the PHP using Ajax. Along with this table data there are 3 text fields on the same form whose data is not added in that table and those text fields data also being sent to the PHP by using Ajax Call. Here is my Save button code.

$("#save").on("click", function (e) {
        e.preventDefault();
        debugger
        if (!iQuantity || !iDiscount) { // This is checking validation.
            $("#message").fadeIn(1000).html(`<div class="alert alert-warning">Please fill all the fields</div>`);
            $("#message").fadeOut(3000);
        } 
              
        if ($("#amountPayable").val() === "" || $("#amountPayable").val() == 0 || $("#amountPaid").val() === "" || $("#amountPaid").val() == 0 
            || $("#discountGiven").val() === "" ) {

            $("#message").fadeIn(1000).html(`<div class="alert alert-warning">Please fill all the fields</div>`);
            $("#message").fadeOut(3000);

        } else {

                var tableData = [];
                $('#addTable tbody tr').each(function () {
                    debugger
                    var rowData = {
                        itemId: $(this).find('td:eq(0)').text(),    // first column in row is trainee  (on index 0)
                        saleId: $(this).find('td:eq(1)').text(),   // second column in row is title
                        qty: $(this).find('td:eq(3)').text(),   // 4th column in row is attend
                        amount: $(this).find('td:eq(4)').text(),  // 5th column in row is trainer                        
                    };
                    tableData.push(rowData);
                });

            var formFields = {   // This takes text fields data
                amountPayable: $("#amountPayable").val(),
                amountPaid: $("#amountPaid").val(),
                discountGiven: $("#discountGiven").val(),
            };

            // Here I'm making object of both above objects.
            var dataToSend = {
                td: JSON.stringify(tableData), // Grid data
                ff: JSON.stringify(formFields), // Text fields data
            };
            

            console.log("ok");
            $("#message").html("");
            debugger
            $.ajax({
                url: "../add-pages/add-orders.php",
                type: "POST",
                data: dataToSend,
                processData: false,
                contentType: false,
                
                success: function (receivedData) {
                    debugger
                    var dt = receivedData;
                    $('#message').fadeIn(1000).html(receivedData);
                    $("#message").fadeOut(3000);

                    // --------------------------------------------- For Claring the Form Fields, ---------------------------------------------
                    $(':input', '#addOrdersData')
                        .not(':button, :submit, :reset, :hidden')
                        .val('')
                        .prop('checked', false)
                        .prop('selected', false);
                    
                    $("#update").attr("disabled", true);
                }
            });
        }
    });

And here is my PHP code where I’m receiving the code:


    <?php
     date_default_timezone_set('Asia/Karachi');

     $tableData = json_decode($_POST['td']); // Grid data
     $ff = json_decode($_POST['ff']); // Grid data
   ?>

The error I received in PHP is:

Warning: Undefined array key “td” in C:xampphtdocssuperStoreadd-pagesadd-orders.php on line 4

Please guide me where the mistake is happening.

Thank you very much, SOF.

How to retrieve stored data by delimiter ( ; ) in MySQL

I have 2 Tables Like these:

region Table:
+----------+-------------+
|region_id | region_name |
+----------+-------------+
|1         | RN1         |
|2         | RN2         |
|3         | RN3         |
+----------+-------------+

and

role Table:
+----------+-------------+
|role_id   | role_name   |
+----------+-------------+
|1         | admin       |
|2         | software    |
|3         | network     |
+----------+-------------+

In my HTML form I get region_id and role_id from Administrator and store using PHP in MySQL table like this:

useraccess Table:
+--------+-----------+
|role_id | region_id |
+--------+-----------+
|1       | 1;2;3     |
|2       | 1         |
|3       | 1;2       |
+--------+-----------+

Well, the problem is I don’t know how to write a query that can retrieve region_name(s) from region table using useraccess table.
for example: when role_id = 1 then region_id is 1;2;3 so instead of 1,2,3 I want to show RN1,RN2,RN3 in my HTML page.

I tried to use for-loop using PHP but it has own limitation and doesn’t work correctly. also I used MySQL SPLIT_STR() function but maybe I can’t get the result. I will appreciate help me to solve this problem.

Which server hosting do I need in this particular situation? [closed]

I have a PHP file which retrieves data from a JSON file and outputs JSON data.
This PHP file will be called 1000 times an hour.

Is there a hosting provider which supports this?

Or do I need a CDN with a Cron Job which runs the PHP file a few times an hour and puts the JSON file on the CDN. Does something like this exists? Can anyone put me in the right direction?

Thanks!

Contacting hosting providers without any luck.

MySQL: How to filter results on columns through a SQL query

I need to know if the following can be resolved with a SQL query and how. I have done it with PHP in different ways but the memory skyrockets and the server takes a long time to return the results. 🙁

  • I have a table called 'parts' with many rows (but many).
  • Each of the rows has the columns part1, part2 and part3, all with different values.

Example:

+---------+-------+-------+
| part1   | part2 | part3 | <-- Column Name
+---------+-------+-------+
| chamber | wheel | door  | <-- Value
+---------+-------+-------+

On the other hand I have a list of three values that come from an external source:

$list = ['mirror', 'seat', 'door'];

I need to select the rows whose columns contain all those values, regardless of the order. An example of a valid row would be:

+-------+--------+-------+
| part1 | part2  | part3 |
+-------+--------+-------+
| door  | mirror | seat  |
+-------+--------+-------+

Sometimes the external list doesn’t have 3 values, just 1 or 2:

$list = ['antenna'];

… Then the valid rows would be those that contain that value, for example:

+--------+--------+---------+
| part1  | part2  | part3   |
+--------+--------+---------+
| engine | mirror | antenna |
+--------+--------+---------+
  • Additional info: In each row, the columns do not have repeated values, so this feature can be ignored in the query.
  • I need to know how to make a query for SELECT and another for COUNT.
  • It is necessary that the result be resolved through a MySQL query, without using PHP for filtering.

Merge ALL CMSs in one CMS

I have 15 website every one have CMS, most websites build with php 7.2 and 8.2 I need to cleect all in one CMS, it is recommended that , or not to merge all websites in one CMS and what factors can face and most take in consideration
Please resolve my query. Thanks in advance.

How does property chaining in between methods work in php

I understand how chaining methods works, I also understand how chaining a property as the last item in the chain works, like this example

$tank = $bmw -> fill(10) -> ride(40) -> tank;

but what about chaining a property in between two methods, how does that work? is the property secretly a method? here is an example

expect(2,2)->not->toBeGreaterThan(3)

I am learning php in the context of laravel so if this is a laravel only thing let me know.

I’ve done my due diligence and looked this up several times but I couldn’t find the answer I am looking for.

Php – Phpdoc typehint when trying to iterate over integer

I have this code

/** @var array{total: integer, records: array} $response */
$response = $this->getResponse();

foreach($response['total'] as $value) {
    $this->saveRecord($value);
}

Shouldn’t PHPStorm give me a warning using PHPDoc static analysis that I’m trying to iterate over $response['total'], which is an integer ?

Laravel query wrong format of value

I’m currently develop a web application with Laravel.
My database engine is a Microsoft SQL Server.

For some data I preferred to generate an uuid.
When I use Windows to run my Laravel app, the uuid format is correct :

  • A5EE121A-1F10-46FC-B779-49D2A0FA3B68

But when I ran my Laravel app under linux, and use the same database, the uuid format is like this :

  • b”x1Ax12î¥x10x1FüF·yIÒ ú;h”

I don’t know where is the problem…
Have you an idea ?

Thanks.

The goal is to retrieve the same format when the Laravel app ran under Windows and under Linux.

Function woocommerce for single product copy and set “value” attibute in brand

I created this woocommerce function that I inserted into the theme’s functions.php file. I want to take the term “value” referring to the “name” of a specific attribute of a single product and insert it as the brand term of that product ID.

The following code doesn’t work, it doesn’t perform the intended function. How to do? Thank you

 // Check if the product is a WooCommerce product
 if (get_post_type($product_id) !== 'product') {
     return;
 }

 
 $product = wc_get_product($product_id);

 
 if (!$product->has_attributes()) {
     return;
 }

 
 $attributes = $product->get_attributes();

 
 foreach ($attributes as $attribute) {
     if ($attribute->get_name() === 'Manufacturer') {
         
         $brand_value = $product->get_attribute('Manufacturer');

         
         if (!empty($brand_value)) {
             // Copy the value into a taxonomy called 'store'
             wp_set_object_terms($product_id, sanitize_text_field($brand_value), 'store', true);
         }
         return;
     }
 }
}

add_action('woocommerce_update_product', 'copy_brand_value_in_taxonomy');