Home > Backend Development > PHP Tutorial > mysql话语配对

mysql话语配对

WBOY
Release: 2016-06-13 13:20:57
Original
826 people have browsed it

mysql语句配对
例如表a新闻表一个新闻所属类别字段newsca为12,14,20,
另一个表b类别表 cid cname
12 14 20 对应的就是cid
现在修改新闻 用复选框
怎么判断新闻所属类别已选
什么数据都能得到 不知道怎么把12,14,20,分开然后配对


------解决方案--------------------
可参考以下例子

PHP code
$ar=array(
  array('id'=>12,'name'=>'分类1'), 
  array('id'=>11,'name'=>'分类2'),
  array('id'=>50,'name'=>'分类3')
);
$f='12,34';
foreach($ar as $v) {
     $k=strpos($f,$v[id]) !==false ? 'checked'  : '';
      echo "<input type="checkbox" value="{$v[id]}">" ;
} <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template