hey all.i'm newbie at this problem.i have this data in table result:
item range_code class
red 123x0001-123x0500 A
blue 123x0021-123x0100 //if null read zero
green 123x0001-123x0300 b
i want the result like:
item qty S A B C
red 500 0 1 0 0
blue 80 0 0 0 0
green 300 0 0 1 0
i have tried this code but still not work:
$sql= 'SELECT item, range_code as qty, class FROM result GROUP BY item, qty';
$result=mysql_query($sql);
while ($row=mysql_fetch_assoc($result)){
preg_match_all('/\d+(?=-|$)/g',$row['qty'],$matches);
echo intval($matches[0][1])-intval($matches[0][0])+1;
}
i still confuse for this problem. please help..