This is a follow on to a previous question.
I have 4 buttons on my home page, each has their own ID associated to them. When someone clicks a button Jquery grabs the button ID and sends it to PHP via Ajax where it is then added as a session variable. If people click multiple buttons it will send the ID of each button. So in the end it is possible that I could have 4 variables in the array.
The Session is created as an array so that it can hold the multiple ID's: Like so:
<?php
session_start();
if ( ! is_array( $_SESSION['ids'] ) ) {
$_SESSION['ids'] = array();
}
if ( ! in_array($_POST['session'], $_SESSION['ids'] ) ) {
$_SESSION['ids'][] = $_POST['session'];
}
?>
That all works correctly and If i print_r $_SESSION['ids'] it correctly shows the id of each button that was clicked and stored e.g:
[0] => 1, null, [1] => 3, null, [2] => 4
(Where the button id's that were stored are 1, 3 and 4.
The issue now is that I need to query the database for the button ID's that have been stored.
How can I break the array up and get just the values e.g: The button ID 1, 3 and 4.
So that I can query the database with them?