I'm trying to find if a word, or string exists within a database field. My scenario is: User fills out a form and submits to MySQL database. A checkbox element on the form saves to the database in a CSV format (Option 1, Option 2, Option 3). I'm using Zend PDF to print a checkbox on a PDF form at certain positions depending on what is checked (IE on the PDF I have the options listed, if Option 2 is selected I want a checkbox next to it, if all 3 are selected then a checkbox needs to appear next to all 3).
I'm using Switch/Case logic to accomplish this:
switch ($row["MySQL_Field"]){
case "Option 1": $page->drawImage($checkmark,20,20,30,30);break;
case "Option 2": $page->drawImage($checkmark,40,40,50,50);break;
case "Option 3": $page->drawImage($checkmark,60,60,70,70);break;
}
Since the Database field can contain 'Option 1, Option 2, Option 3', I'm trying to figure out how to query so it looks like:
case "[0+ of any character]Option 1[0+ of any character]": do this;
What would be the best way to go about this? Thanks!
Aucun commentaire:
Enregistrer un commentaire