Problem sending array from Controller to Model in Codeigniter

Good evening. For learning purposes I am building a CRUD script with the possibility for drag and drop rows using ajax. While sending the data from the controller to the model, my model function is unable to treat the array so I am encountering a problem.

Good evening. For learning purposes I am building a CRUD script with the possibility for drag and drop rows using ajax. While sending the data from the controller to the model, my model function is unable to treat the array so I am encountering a problem.

Controller function:

public function from_ajax() {
    $this->load->model('model');
    $ordem = $this->input->post('ordem');
    parse_str($ordem, $array_ordenado);
    var_dump($array_ordenado); //testing only
    $resultado = $this->model->reordem($array_ordenado);
    echo json_encode($resultado);           
}

var_dump on controller output:

array(1) { ["teste"]=> array(4) { [0]=> string(1) "1" [1]=> string(1) "3" [2]=> string(1) "2" [3]=> string(1) "4" } }

Here is my model function:

public function reordem($data) {
    $this->db->select('page_order');
    $this->db->from('tbl_posts');
    return $this->db->update('tbl_posts', $data);
}

How would I treat this array dump on my model function so I can get the value I want (the ones inside "")?

I'm also getting this error: php/database error Thank you for your time!

Cannot send array to php via AJAX?

Well I followed&nbsp;<a href="https://stackoverflow.com/questions/9001526/send-array-with-ajax-to-php-script" target="_blank">this</a>&nbsp;question, but cannot send array to php it returns me always empty:

Well I followed this question, but cannot send array to php it returns me always empty:

JS:

            values = [];
            values['mpsRegnomer'] = $('#mpsRegnomer').val();
            values['mpsMarka'] = $('#mpsMarka').val();
            values['mpsMarkaOther'] = $('#mpsMarkaOther').val();
            values['engineType'] = $('#engineType').val();
            values['seatNumberInput'] = $('#seatNumberInput').val();
            values['carColor'] = $('#carColor').val();
            values['mpsChassiNum'] = $('#mpsChassiNum').val();
            values['mpsModel'] = $('#mpsModel').val();
            values['mpsModelOther'] = $('#mpsModelOther').val();
            values['mpsManufactureDate'] = $('#mpsManufactureDate').val();
            values['mpsfor'] = $('#mpsfor').val();
            values['VehicleType'] = $('#VehicleType').val();
            values['dvigatelInput'] = $('#dvigatelInput').val();
            values['engineMaxPower'] = $('#engineMaxPower').val();
            values['is_automatic'] = $('#is_automatic').val();
            console.log(values);
        $.ajax({
                type: 'POST',
                url: 'assets/clients/services/saveDataMPS.php',
                async: false,
                dataType: "JSON",
                data: {"values": JSON.stringify(values)},
                success:function(response){
                    alert(1);
                }
        });

console.log(values) show me that array is OK.

PHP code:

<?php

var_dump(json_decode($_POST["values"])); exit;

It returns me always empty, also tried only with var_dump($_POST); same result.. Where am I wrong?

Result from console.log(values):


PHP Interview Questions with Solutions: Prepare for PHP Interview

PHP Interview Questions with Solutions: Prepare for PHP Interview

Prepare for PHP Interviews. Set Variable With php.ini File. Logic & Output Behind PHP Code Segment. Class Concept, Error & Functions in PHP. Start PHP Now!

Description
In this course you will be introduced with some tricky questions that everyone face during their interview. In each solutions I have included some useful functions which we generally use at the time of development also. I have covered the following area in my course with Questions, Attractive Presentations and Practical Solutions that will help you to understand the logic behind PHP in a different way.

Some useful functions
PHP error types
Class concept
Access specifiers public, private and protected
Set variable with php.ini file
Operators introduced in PHP7
Logic and its output behind some code segment
Basic knowledge
PHP7, XAMPP Server, Notepad++
What will you learn
This course is build for the person who is facing interviews. Every question is well explained with the practical solution through videos. So that everybody can prepare themselves for the tricky questions asked during interviews
To continue:

Advantages of Hiring PHP Developer for your Website Project

Advantages of Hiring PHP Developer for your Website Project

PHP - Hypertext pre-processor, a scripting language used by many people in developing web pages, but most of us are unaware even of the full form. To train someone and make them learn this whole language is as difficult and time-consuming as it is...

PHP - Hypertext pre-processor, a scripting language used by many people in developing web pages, but most of us are unaware even of the full form. To train someone and make them learn this whole language is as difficult and time-consuming as it is to learn the language yourself. That’s why PHP developers are there to make your life easy. This article will give us the advantages and requirements of Hire PHP Developer for our very own website project.

First of all, let us understand the value the right developer brings to the project and why it is important for your business.

A website is a major component of any company/business and is very important for its face value, the way it represents the company on the internet is critical for any business to succeed. This is the reason why companies are looking for PHP developers who can develop their webpage.

If you're planning to do an online business, your PHP programmer will be the first person to transfer your thinking onto the webpage. You should, therefore, employ developers from PHP to make your hypothetical idea a reality.

With this software programming language, PHP developers all-around can easily build website frameworks, web content management systems, web template systems, and various other web-based designs.

Some of the reasons why we need to outsource these developers are:

Not everyone is the best in each field, all of us have our specific skills and talents hence, PHP developers are also the best at what they do. The time and money spent on the training of the in house employees would be saved if the professional PHP developers are hired. Instead of multitasking, if the employees were to focus on what they’re good at it would increase productivity too.

The PHP developers would be much more professional than the in-house workers. It would lead to the seriousness of work. Hence, on-time delivery is guaranteed with hired PHP developers.

In addition to these benefits, you would also be able to track your project through every stage in constant communication with your online team. These advantages make it incredibly popular and smart to hire a PHP developer.

The PHP developers have in-depth knowledge of PHP, HTML and various frameworks in terms of technical capabilities. Hiring PHP developers are advised to give your website a professional look based on PHP.

Much of web success depends on the involvement of social media. The developer can add to your social networking pages a feature that explicitly redirects visitors. In addition, SEO experts also suggest better connections to the website's social network.

Just like a tailor stitches our dresses according to our preferences and is ready to make last-minute changes. A PHP developer will also be available at the nick of your call to make the website just the way you want it to be and have a customized solution for every problem.

Read also: Why & How to Hire Dedicated PHP Developer

At some point in your business, you’re going to have problems regarding your webpage due to the rapidly changing technology, instead of struggling with ideas like these and not being able to come up with an appropriate solution a PHP web developer could help us with our problems just like any technician would help us with the problems we face in our offices or any architect would help us with designing the structure of a building or any interior designer would help us with setting up our home. The PHP development company are hubs of workers who would help us overcome these problems and are always there.

Source by