title: How to locate if session var is in comma separated column?
body: <p>I have comma separated column in my database. That column called 'access' it handles number such as 1,2,3,4,5,6,7. The requirement that I need to compare the value of my session is called kt_department with one of the comma separated value like for example the value of kt_department is 4, then the rest of the data will show in the page. But if not it will proceed to the next row, but if again it is not found it should proceed to the next row until it found its value in comma separated. But if they found nothing, a message like <strong>"no available record"</strong> will appear. And also the record found should be count. </p>
  
  <p>I tried to wright my own;</p>
  
  <pre><code>&lt;?php 
              $news_connect = mysqli_connect("localhost","root","pwd", "dbase");
              if (mysqli_connect_errno())
                  {
                      echo "Failed to connect to MySQL: " . mysqli_connect_error();
                  }
              $kt_dept  = $_SESSION['kt_department'] . " ";
              $accessrights = explode(',', $row_news['accessrights']);
              $news_query = "SELECT * FROM memo
                             WHERE (access LIKE '%{$accessrights}%' AND status='1' AND idcategory='1')";
              $news_result = mysqli_query($news_connect, $news_query);
              $row_news = mysqli_fetch_array($news_result);
              echo $kt_dept; 
              ?&gt;
              &lt;div style="margin-top:30px;"&gt;
              &lt;table width="98%"  border="0" cellspacing="5" cellpadding="0" class="curveborderboxnobg"&gt;
                    &lt;tr&gt;
                      &lt;td height="70" colspan="2" class="brandtitle" style="padding-left:20px;line-height:60px; font-size:18px;"&gt;&lt;img src="images/icons/news-announcement.png" width="20" height="20" style="margin-right:10px;"&gt;&lt;strong&gt;News and Announcement &lt;/strong&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                      &lt;td height="40" colspan="2" style=" padding:0px 20px 0 20px;"&gt;
                      &lt;table width="95%"  border="0" style="margin-left:45px;" class="bortopbot" cellpadding="0" cellspacing="5"&gt;
                        &lt;tr&gt;
                          &lt;td height="30" class="tabledetails" style="padding-top:20px;" &gt;&lt;strong&gt;&lt;a href="news_bulletin.php?idmemonewsbulletin=&lt;?php echo $row_news['idmemo']; ?&gt;" class="lightbox" data-width="800" data-height="500"&gt;&lt;?php echo $row_news['title']; ?&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                          &lt;td class="tabledetails" style="padding-bottom:20px;"&gt;&lt;span style="font-size:12px;"&gt;&lt;?php echo $row_news['shortdesc']; ?&gt;&lt;/span&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                      &lt;/table&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                      &lt;td height="40" class="tabledetails" style="padding-left:10px;"&gt;&amp;nbsp; &lt;/td&gt;
                      &lt;td class="tabledetails" style="padding-right:20px; "&gt;
                      &lt;table width="263" border="0" align="right" class="tabledetails"&gt;
                        &lt;tr&gt;
                          &lt;td align="center"&gt;&lt;div align="right"&gt;&lt;a href="news_bulletin_list.php?newsbul=&lt;?php echo $row_news['idcategory']; ?&gt;"&gt;&lt;strong&gt;View All &lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                      &lt;/table&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;            
              &lt;/div&gt;
                  &lt;table width="98%"  border="0" cellspacing="5" style="margin-top:30px; " cellpadding="0" class="curveborderboxnobg"&gt;
                    &lt;tr&gt;
                      &lt;td height="70" class="brandtitle" style="padding-left:20px;line-height:60px; font-size:18px;"&gt;&lt;img src="images/icons/news-announcement.png" width="20" height="20" style="margin-right:10px;"&gt;&lt;strong&gt;News and Announcement &lt;/strong&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                      &lt;td height="40" class="bortopbot" style=" padding:0px 20px 0 20px;"&gt;
                        &lt;div align="center"&gt;- No News and Announcement - &lt;/div&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
                &lt;?php mysqli_close($news_connect); ?&gt;
  </code></pre>
  
  <p>Thank you guys. Please help me. thanks!</p>