PHP MySql Database Array update

jae.phoenix

I am trying to update one row in my database like this.

if (isset($_POST['submit'])) {
$sizes = array($_POST['size_king'], 
               $_POST['size_queen'],
               $_POST['size_double']
              );

mysqli_query($con, "UPDATE beds 
                SET `Available Sizes` = '$sizes' 
                WHERE ID = '$prod_id' " 
            );
}

Can anyone please help me?

I want this data to only update one row, and the data must be separated by a comma.

I am thinking maybe a FOR loop, but I'm not quite sure.

Rajeev Ranjan

just use implode() function .

if (isset($_POST['submit'])) {
$sizes = array($_POST['size_king'], 
               $_POST['size_queen'],
               $_POST['size_double']
              );
$sizes=implode(",",$sizes);
mysqli_query($con, "UPDATE beds 
                SET `Available Sizes` = '$sizes' 
                WHERE ID = '$prod_id' " 
            );
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MYSQL and PHP database update wont update database

From Dev

Update MySQL database with PHP and AJAX

From Dev

Insert and update database with php mysql

From Dev

Update database using MySQL and PHP

From Dev

Update MySQL with an Array using PHP

From Dev

php update to mysql with array not updating

From Dev

PHP not inserting array into MySQL database

From Dev

Creating JSON Array in Swift to update MySQL database

From Dev

Update value in mysql database column with checkbox in php

From Dev

Mysql and PHP - Update database from a different server

From Dev

php mysql update database on button click

From Dev

Update value in mysql database column with checkbox in php

From Dev

Database - mySQL and PHP updating conflicting information on update

From Dev

Update MySQL database using php statement

From Dev

PHP/MySQL Update database on session timeout

From Dev

Get user id for database update - PHP/MySQL

From Dev

Trying to update mysql database form in php

From Dev

PHP & MySql: can't update database

From Dev

cannot update quantity in stock on database php/mysql

From Dev

Update blob image in Database with UPDATE MySQL using PHP

From Dev

Mysql UPDATE using PHP and AJAX, can't update database

From Dev

update mysql table where rows are not in php array

From Dev

PHP Mysql Update Serialize Array in escape apostrophe

From Dev

JS array to PHP and update table in MYSQL with PDO

From Dev

PDO UPDATE array using php mysql

From Dev

JS array to PHP and update table in MYSQL with PDO

From Dev

PHP MySQL UPDATE query with array and IN statement

From Dev

How to store an Array in Database (PHP/MySQL)?

From Dev

Massive PHP array vs MySQL Database?

Related Related

HotTag

Archive