查詢數組中摸個欄位的個數?解決思路

來源:互聯網
上載者:User
查詢數組中摸個欄位的個數?
$r=mysql_query('select orderid,zhuangtai,group_concat(`name`) as name,group_concat(`shouji`) as shouji,group_concat(`sex`) as sex from `order` group by orderid');
echo "











"; echo " ";while($row=mysql_fetch_assoc($r)){ $shouji_arr=explode(',',$row['shouji']); $sex_arr=explode(',',$row['sex']); echo " "; foreach(explode(',',$row['name']) as $k=>$v){ echo " "; echo " "; echo " "; }}echo "
姓名 手機 性別
訂單號:".$row[orderid]." 狀態:".$row['zhuangtai']."
$v $shouji_arr[$k] $sex_arr[$k]
";


這是一個迴圈輸出的列子,我想知道,怎麼得到
$v$shouji_arr[$k]$sex_arr[$k]
中,$v的個數呢? 意思就是,怎麼得到實際輸出顯示之後,這個有多少行呢?因為我需要增加一個合并的儲存格,類似與 合并的儲存格 因為不知道這組中有多少行,也就是$v的個數,所以不知道rowspan 這個值是多少!


不知道我的表述,大家聽沒聽清楚,就是 這個foreach 輸出顯示,但是不能確定輸出多少行,需要得到$v的個數,因為一個$v佔一行! mysql php table border


------解決方案--------------------
$t = explode(',',$row['name']);
$s = "合并的儲存格的內容";
foreach($t as $k=>$v){
echo "" . $s;
echo "$v$shouji_arr[$k]$sex_arr[$k]";
echo "";
$s = ''; //輸出過了就清空
}
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.