对从数据库检索的多个选择执行添加

时间:2016-04-17 12:01:24

标签: php mysql

我正在从mysql表中检索多个选项。我想添加选项以获得一些总数。我的代码看起来像这样

<tr>
    <td>Categories</td>
    <td>
      <label for="txtClassification"></label>
      <div id="suggest">
          <input type="text" value="" id="txtClassification" onkeyup="suggest(this.value);" onblur="fill();" class="MyTextBox" />         
          <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="images/arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />          
            <div class="suggestionList" id="suggestionsList"> &nbsp; </div>          
          </div>
        <input name="cmdAddClass" type="submit" class="TempAddClass g-button-small" id="cmdAddClass" value="+" />
      </div> 
    </td>
  </tr>

,数据库代码就像这样

if ($i && $count>0){
  $clsql = "SELECT clc_clscode FROM  `tblclientdetails_classcode`  where  `clc_cldcode` =  '$i'";
  $clresult =$sql->Select($clsql);
    $e= count($clresult);
    if (count($clresult)){
        $classnames ='';
        for ($j=0;$j<$e;$j++) {
            $d = $clresult[$j]['clc_clscode'];
            $clasisql = "SELECT cls_name,cls_code FROM `tblclassification` where  `cls_code` =  '".$d."' ORDER by 'cls_name'";
            $clasiresult =$sql->Select($clasisql);
            $clasicount = count($clasiresult);
            if ($clasicount > 0)
            for ($k=0;$k<$clasicount;$k++){
               $classURL=str_replace(" ","-",$clasiresult[$k]['cls_name']);
               $classnames .= '<a href="classilist.php?c='.$clasiresult[$k]['cls_code'].'&name='.$classURL.'" title ="'.  $clasiresult[$k]['cls_name'].'" class="btn">'.$clasiresult[$k]['cls_name'].'</a>';
            }           
            for ($meta=0;$meta<$clasicount;$meta++){ //for meta keywords
               @$metaclassnames .= $clasiresult[$meta]['cls_name'].', ';
            }
        }   
    }
} 

我想添加检索到的结果并得到一些总数。

0 个答案:

没有答案