Quote:$sql_query1 = "UPDATE movies_info SET `movie_name`='$movie_name',`movie_original_name`='$movie_original_name',`movie_image`='$target',
`movie_description`='$movie_description',`movie_stars`='$movie_stars',`movie_director`='$movie_director',
`movie_trailer`='$movie_trailer',`release_date`='$release_date',`release_year`='$release_year',`movie_genre`='$movie_genre',
`movie_rating`='$movie_rating',`movie_country`='$movie_country',`movie_runtime`='$movie_runtime',
`is_featured`='$is_featured' WHERE `movie_id`='$movie_id'";
I see a few problems.
First of all, if you enclose a variable in single quotes, it will be taken as a literal string, not as it's value.
In CI, you can pass an associated array to the $this->db->update() function, like this:
PHP Code:
$data = array(
'movie_name' => $movie_name,
'movie_original_name' => $movie_original_name,
'movie_director' => $movie_director,
);
$this->db->where('id', $movie_id)->update('table_name', $data);
(It works the same if you pass the $data to your model).
Another thing is how you convert the array of countries to a comma separated string.
You can use php's implode function:
PHP Code:
$movie_country = implode(',' , $this->input->post('movie_country'));
If you read it back from your database, use explode() to convert it to an array.
A better method for storing an array into a table field in your database is php's serialize:
PHP Code:
$movie_country = serialize($this->input->post('movie_country'));
Serialize doesn't only store the array's values, but also the keys, variable-types and string-lengths. It will code all this information into a string.
Use unserialize() to convert it back to an array.