Reputation: 167
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?
Upvotes: 1
Views: 104
Reputation: 4237
Try use the code from this example:
// here gets //selects the row with BUG IDs
$bug_id = '3743200,3743234,3743212';
$arrids = explode(',', $bug_id);
$links = '';
for($i=0; $i<count($arrids); $i++) {
$links .= '<br/><a href="show_bug.cgi?id='.trim($arrids[$i]).'">'.$arrids[$i].'</a>';
}
echo $links;
Upvotes: 1
Reputation: 12033
You can use explode function.
$ids = explode(',', $bugs);
foreach($bugs as $b) {
echo '<a href="...">'.$b.'</a>';
}
Upvotes: 1
Reputation: 1747
$bugIdString="3743121,3743125,3743126,3743193";
$bugIdArray=explode(",",$bugIdString);
foreach($bugIdArray as $bug_id){
echo "<a href='show_bug.cgi?id=$bug_id'>$bug_id</a>, ";
}
Upvotes: 2