Setting an Array inside a prepared SQL statement
<p>I was told that "There is no way to bind an array to an SQL statement using prepared statements" but I have done it. I am having trouble recreating it though. </p>

<p>I have a statement that updates the database:</p>

<pre><code>if (isset($_POST['printRow'])){
$ids = "";
foreach ($_POST['checkbox'] as $rowid)
{
        if(!empty($ids)) $ids .= ',';
        $ids .= $rowid;
        $_SESSION['ids'] = $ids;
}
}
</code></pre>

<p>Here I forgot to post the WORKING code:</p>

<pre><code>$stmt = $conn-&gt;prepare("UPDATE just_ink SET deleted=1 WHERE ID IN( " . $ids . ")");
    $stmt-&gt;execute();
</code></pre>

<p>But I still have the following problem: </p>

<p>Where $ids can be either one or multiple ids. </p>

<p>So here is the problem, if I try to take $ids and set a SESSION with it </p>

<pre><code>($_SESSION['ids'] = $ids;)
</code></pre>

<p>For use on another page. </p>

<p>On the next page I want to select data using $_SESSION['ids'] so, </p>

<pre><code>$stmt = $conn-&gt;prepare("SELECT * FROM just_ink WHERE ID IN( " . $_SESSION['ids'] . ")");
$stmt-&gt;execute();
</code></pre>

<p>But this doesn't work. Any ideas why?</p>