i have the next info stored in a wp table

s:22:"seasonal_prices_schema";a:37:{i:1;a:3:{s:4:"from";s:10:"2017-05-11";s:2:"to";s:10:"2017-05-12";s:5:"index";s:1:"1";}i:2;a:3:{s:4:"from";s:10:"2017-05-13";s:2:"to";s:10:"2017-05-14";s:5:"index";s:1:"2";}i:3;a:3:{s:4:"from";s:10:"2017-05-15";s:2:"to";s:10:"2017-05-19";s:5:"index";s:1:"3";}i:4;a:3:{s:4:"from";s:10:"2017-05-20";s:2:"to";s:10:"2017-05-21";s:5:"index";s:1:"4";}i:5;a:3:{s:4:"from";s:10:"2017-05-22";s:2:"to";s:10:"2017-05-26";s:5:"index";s:1:"5";}i:6;a:3:{s:4:"from";s:10:"2017-05-27";s:2:"to";s:10:"2017-05-28";s:5:"index";s:1:"6";}i:7;a:3:{s:4:"from";s:10:"2017-05-29";s:2:"to";s:10:"2017-06-02";s:5:"index";s:1:"7";}i:8;a:3:{s:4:"from";s:10:"2017-06-03";s:2:"to";s:10:"2017-06-04";s:5:"index";s:1:"8";}i:9;a:3:{s:4:"from";s:10:"2017-06-05";s:2:"to";s:10:"2017-06-09";s:5:"index";s:1:"9";}i:10;a:3:{s:4:"from";s:10:"2017-06-10";s:2:"to";s:10:"2017-06-11";s:5:"index";s:2:"10";}i:11;a:3:{s:4:"from";s:10:"2017-06-12";s:2:"to";s:10:"2017-06-16";s:5:"index";s:2:"11";}i:12;a:3:{s:4:"from";s:10:"2017-06-17";s:2:"to";s:10:"2017-06-18";s:5:"index";s:2:"12";}i:13;a:3:{s:4:"from";s:10:"2017-06-19";s:2:"to";s:10:"2017-06-23";s:5:"index";s:2:"13";}i:14;a:3:{s:4:"from";s:10:"2017-06-24";s:2:"to";s:10:"2017-06-25";s:5:"index";s:2:"14";}i:15;a:3:{s:4:"from";s:10:"2017-06-26";s:2:"to";s:10:"2017-06-30";s:5:"index";s:2:"15";}i:16;a:3:{s:4:"from";s:10:"2017-07-01";s:2:"to";s:10:"2017-07-02";s:5:"index";s:2:"16";}i:17;a:3:{s:4:"from";s:10:"2017-07-03";s:2:"to";s:10:"2017-07-07";s:5:"index";s:2:"17";}i:18;a:3:{s:4:"from";s:10:"2017-07-08";s:2:"to";s:10:"2017-07-09";s:5:"index";s:2:"18";}i:19;a:3:{s:4:"from";s:10:"2017-07-10";s:2:"to";s:10:"2017-07-14";s:5:"index";s:2:"19";}i:20;a:3:{s:4:"from";s:10:"2017-07-15";s:2:"to";s:10:"2017-07-16";s:5:"index";s:2:"20";}i:21;a:3:{s:4:"from";s:10:"2017-07-17";s:2:"to";s:10:"2017-07-21";s:5:"index";s:2:"21";}i:22;a:3:{s:4:"from";s:10:"2017-07-22";s:2:"to";s:10:"2017-07-23";s:5:"index";s:2:"22";}i:23;a:3:{s:4:"from";s:10:"2017-07-24";s:2:"to";s:10:"2017-07-28";s:5:"index";s:2:"23";}i:24;a:3:{s:4:"from";s:10:"2017-07-29";s:2:"to";s:10:"2017-07-30";s:5:"index";s:2:"24";}i:25;a:3:{s:4:"from";s:10:"2017-07-31";s:2:"to";s:10:"2017-08-04";s:5:"index";s:2:"25";}i:26;a:3:{s:4:"from";s:10:"2017-08-05";s:2:"to";s:10:"2017-08-06";s:5:"index";s:2:"26";}i:27;a:3:{s:4:"from";s:10:"2017-08-07";s:2:"to";s:10:"2017-08-11";s:5:"index";s:2:"27";}i:28;a:3:{s:4:"from";s:10:"2017-08-12";s:2:"to";s:10:"2017-08-13";s:5:"index";s:2:"28";}i:29;a:3:{s:4:"from";s:10:"2017-08-14";s:2:"to";s:10:"2017-08-18";s:5:"index";s:2:"29";}i:30;a:3:{s:4:"from";s:10:"2017-08-19";s:2:"to";s:10:"2017-08-20";s:5:"index";s:2:"30";}i:31;a:3:{s:4:"from";s:10:"2017-08-21";s:2:"to";s:10:"2017-08-25";s:5:"index";s:2:"31";}i:32;a:3:{s:4:"from";s:10:"2017-08-26";s:2:"to";s:10:"2017-08-27";s:5:"index";s:2:"32";}i:33;a:3:{s:4:"from";s:10:"2017-08-28";s:2:"to";s:10:"2017-09-01";s:5:"index";s:2:"33";}i:34;a:3:{s:4:"from";s:10:"2017-09-02";s:2:"to";s:10:"2017-09-03";s:5:"index";s:2:"34";}i:35;a:3:{s:4:"from";s:10:"2017-09-04";s:2:"to";s:10:"2017-09-08";s:5:"index";s:2:"35";}i:36;a:3:{s:4:"from";s:10:"2017-09-09";s:2:"to";s:10:"2017-09-10";s:5:"index";s:2:"36";}i:37;a:3:{s:4:"from";s:10:"2017-09-11";s:2:"to";s:10:"2018-02-28";s:5:"index";s:2:"37";}}

And when i try to print dates as a table i get an error using:

while($row = mysqli_fetch_array($result)){

    $mydata = $row['option_value'];
    $data = unserialize($mydata);
    $tabel = $data['seasonal_prices_schema'];
    foreach($tabel as $linie) {

        $from = $linie['from'];
        $to = $linie['to'];

        echo '<tr>';
        echo '<td>' . $from . '</td>';
        echo '<td>' . $to . '</td>';
        echo '</tr>';

    }

}

The error is: Warning: Invalid argument supplied for foreach() in x.php on line 102

-> foreach($tabel as $linie)

When i paste the following stored dates into $mydata = ”; it prints it, but when i’ve put the info from db isnt working.

Sorry for my english, if you have any idea.

Thanks

Read more here: Unserialize from WP database, booking dates


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: