I'm struggling to pull data using PHP from an array stored as LONGTEXT in a MySQL table.
I'm creating a notification script that pulls from two separate tables ('events' and 'bookings'). Amongst other columns, the 'bookings' table is structured like so, with a LONGTEXT array stored in the 'booking_meta' column:
+------+------+------------+------------------------+
| booking_id | event_id | booking_meta |
+------+------+------------+------------------------+
| 1 | 12 | (example array below) |
| 2 | 12 | |
| 3 | 12 | |
| 4 | 12 | |
| 5 | 13 | |
| 6 | 13 | |
| 7 | 13 | |
+------+------+------------+------------------------+
Example array:
a:1:{s:12:"registration";a:5:{s:10:"user_email";s:14:"test@email.com";s:9:"user_name";s:9:"Full Name";s:10:"first_name";s:4:"Full";s:9:"last_name";s:4:"Name";s:10:"dbem_phone";s:8:"12345678";}}
Essentially, i'd like to pull the 'user_name' and 'dbem_phone' from the array in 'booking_meta' and echo it in a list of all bookings in the next 15 minutes. Everything in the following query works, but i have no idea how to parse this array on top of what's already going on:
$bookingresult = mysqli_query($con,"SELECT * FROM events, bookings
WHERE event_start_date='$date' AND event_start_time BETWEEN '$currenttime' and '$currenttime15' AND events.event_id = bookings.event_id");
echo "Bookings for events in the next 15 minutes: <br>";
while($row = mysqli_fetch_array($bookingresult)) {
echo $row['booking_id'] . " " . $row['event_name'];
$phonedata = mysqli_fetch_array($row['booking_meta']);
echo $phonedata['phone'];
echo "<br>";
}