Paulqvz Posted March 3, 2022 Share Posted March 3, 2022 Hi all. I call a stored proc from mysql and show it in php html. function CreateTableRow($RowItem){ $rowHtml = "<tr border: 1px solid black; border-collapse: collapse;>"; $array = get_object_vars($RowItem); foreach($array as $keyItem => $value){ $rowHtml .= "<td border: 1px solid black; border-collapse: collapse;>{$value}</td>"; } $rowHtml .= "</tr>"; return $rowHtml; } This works great, but i am now stumped on how to get it to when it finds a cell with 0 value to use previous value thats not 0. I tried fixing it in mysql with stored proc but it does not make all 0 with previous value. Here is my sql. SELECT GROUP_CONCAT( DISTINCT CONCAT( 'case when sum(if(t.ipDATE = ''',ipDATE,''', t.market_value_1, 0)) = 0 and SUM(IF(t.ipDATE = date_sub(''',ipDATE,''',interval 1 day), t.market_value_1, 0)) = 0 then round(SUM(IF(t.ipDATE = date_sub(''',ipDATE,''',interval 2 day), t.market_value_1, 0)),6) when sum(if(t.ipDATE = ''',ipDATE,''', t.market_value_1, 0)) = 0 then round(SUM(IF(t.ipDATE = date_sub(''',ipDATE,''',interval 1 day), t.market_value_1, 0)),6) else round(sum(if(t.ipDATE = ''',ipDATE,''', t.market_value_1, 0)),6) end AS `',CONCAT(ipDATE),'`' ) ORDER BY YEAR(ipDATE) ASC, MONTH(ipDATE) ASC,DAY(ipDATE) ASC ) INTO @sql But this does not work for when there a 6 dates in a row with 0 values Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 6, 2022 Share Posted March 6, 2022 At minimum, I think we will need the structure of your table(s). We need some typical/sample data Need to know the structure of a $RowItem You need to further explain what you mean by "when it finds a cell with 0 value to use previous value thats not 0." What is "it". How rules exactly, will dictate a value to replace a "0" and why is that needed? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.