Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Check if data is in a table if so pass it to $_SESSIONS array
    primarykey
    data
    text
    <p>Hi guys this is my first post here, there have been similar questions on this forum but I couldn't find one which accurately answered my question or at least it wasn't relevant enough for me to workout an answer - this is my 3rd day using PHP so I am still getting used to it..</p> <p>I am making a small game for my site where by users can pay a small amount of money to win a prize, the prize is a code which will be emailed to them.</p> <p>Currently I have my database and script setup so that the same code cannot be issued twice using the boolean Available which is set to 1 if the code has not been issued and 0 if it has</p> <p>I have my code table setup like so</p> <pre><code>CodeID | ItemID | CodeType | Available | Code | 1 | 1 | xxxxxxx | 1 | QLLxbttKQcHv4e4k | 2 | 1 | xxxxxxx | 1 | 6JKMumiH35Dke4SS | 3 | 3 | xxxxxxx | 0 | mQ2WyUjqNy5fJiEr | </code></pre> <p>What I want to do is check each code to see if it is available, if it is I want to take the ItemID and put it in a $_SESSIONS array which I can use in another page to only return results for codes that I have stocked</p> <p>I am having some trouble checking if the code is available and if it is putting the ItemID in the $_SESSIONS array</p> <p>Currently I have this to query the database</p> <pre><code>$stock = $conn -&gt; query('SELECT * FROM codes WHERE Available = 1'); </code></pre> <p>This checks the database and out puts all codes which are currently available, including duplicate ItemIDs</p> <p>Can anyone help me so that I only take 1 of each ItemID and put that into the $_SESSIONS array which I can use on the next page to only show results with available codes?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload