How To Store Arrays in MySQL Database



How To Store Arrays in MySQL Database


 The following is a tutorial for storing arrays in the WordPress database, partially for public use and personal use. 


Storing arrays with wp_option:


1.) Get data from the column in this case the option_value column in  wp_options.


2.) Run array_push


3.) Update the database with combined array with update_option.





Making a form: 




This is going to be the logic that fires AFTER the user presses submit/save. 


    if (isset($_POST['add_song'])) {

        $wpdb->update(

                $table_name, //table

                array('songs' => $songs), //where

                array('ID' => $id), //where

        );

?>

<h1>Artists</h1>

<div class="updated"><p>Artist song added</p></div>

            <a href="<?php echo admin_url('admin.php?page=ParentPageLMS') ?>">&laquo; Back to Artists list</a>

<?

var_dump($songs);

    }



==========================



Structuring the php array: 




$songs_list = $_GET["songs"];


// $song_list_array = array();

// $song_list_array = array_push(







Comments