想要在数组中单独指向逗号分隔的字符串(want to give separate link to comma seperated string in an array)

编程入门 行业动态 更新时间:2024-10-25 03:29:41
想要在数组中单独指向逗号分隔的字符串(want to give separate link to comma seperated string in an array)

我有下表:

在查询中,我使用group_concat来获取bug id。 我想给每个bug id单独链接。 例如:给出的链接是“show_bug.cgi?id = 3743200”

以下是代码,我用过:

$query = "select count(cbm.bug_id) as count,(select concat(round((count(cbm.bug_id)/(select count(*) from techzilla.category_bug_map cbm,techzilla.bugs b where b.assigned_to =$userId and cbm.bug_id=b.bug_id) * 100 ),2),'%')) as Percentage ,group_concat(b.bug_id separator ',') as BugIds from techzilla.bugs b left join techzilla.category_bug_map cbm on cbm.bug_id = b.bug_id where b.assigned_to = $userId and b.creation_ts >= '$fromDate 00:00:00' and b.creation_ts <= '$toDate 00:00:00' and cbm.os IN ('$opess')"; $result = mysql_query($query) or die ("Bad query: " . mysql_error() ); while($row = mysql_fetch_row($result)) { echo "<tr><td>$opess</td> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td></tr>"; }

我怎样才能做到这一点?

I have the following table :

In the query I have used group_concat to take the bug id's. I want to give separate link to each bug id. for eg : link to be given is "show_bug.cgi?id =3743200"

following is the code, I have used :

$query = "select count(cbm.bug_id) as count,(select concat(round((count(cbm.bug_id)/(select count(*) from techzilla.category_bug_map cbm,techzilla.bugs b where b.assigned_to =$userId and cbm.bug_id=b.bug_id) * 100 ),2),'%')) as Percentage ,group_concat(b.bug_id separator ',') as BugIds from techzilla.bugs b left join techzilla.category_bug_map cbm on cbm.bug_id = b.bug_id where b.assigned_to = $userId and b.creation_ts >= '$fromDate 00:00:00' and b.creation_ts <= '$toDate 00:00:00' and cbm.os IN ('$opess')"; $result = mysql_query($query) or die ("Bad query: " . mysql_error() ); while($row = mysql_fetch_row($result)) { echo "<tr><td>$opess</td> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td></tr>"; }

How can I achieve this?

最满意答案

您可以使用爆炸功能。

$ids = explode(',', $bugs); foreach($bugs as $b) { echo '<a href="...">'.$b.'</a>'; }

You can use explode function.

$ids = explode(',', $bugs); foreach($bugs as $b) { echo '<a href="...">'.$b.'</a>'; }

更多推荐

本文发布于:2023-07-30 01:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321392.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:逗号   字符串   组中   give   separate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!