lundi 10 octobre 2016

Explode database string and compare value with another string in php

I'm stucked in a part of my project where I need to compare the checkbox input i got in my database with another value.

I need to split the input using explode and compare each of the values to see if any of them matches with a list of inputs. If any of them does, I want to echo the values of the ones that matches.

Splitting the input worked but comparing isn't working. Below is my code.

            <?php
            $cou = explode(',' , $row_rsCourse['courses']);
            foreach($cou as $mark){
                $mark1 = $mark."<br>";
                    }

                if ($mark1 = $row_rsCourselist['code'] ){echo $row_rsCourselist['name'];}else {echo "Failed";}
            ?>


                /*
                For example: 
                $row_rsCourse['courses'] = (a,b,d,g,i)
                $row_rsCourselist['code'] = is a database column which contains letters a - z in different input
                $row_rsCourselist['name'] = is a database column which contains names from a - z in different inputs e.g (Andre Ben Charlie etc)
                */

Aucun commentaire:

Enregistrer un commentaire