Home  >  Article  >  Backend Development  >  mysql话语配对

mysql话语配对

WBOY
WBOYOriginal
2016-06-13 10:33:53898browse

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>
Statement:
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
Previous article:PHP ming有关问题Next article:php 怎么显示所属类别