PHP while loop dynamic rowspan -
consider table example
using these table wanted print table these adding rowspan item id 1002.
here php code
$temp_val = ''; $counter = 1; $sql_sel = mysqli_query($con,"select * item_table"); while($res_sel = mysqli_fetch_array($sql_sel)){ if($temp_val == $res_sel['item_id']){ $counter++; echo "<tr></tr>"; } else{ echo "<tr><td rowspan='".$counter."'>".$res_sel['item_id']."</td></tr>"; } $temp_val = $res_sel['item_id']; } echo "</table>";
it's not correct, it's adding rowspan item id 1003
you should switch code inside else
, if
statement
Comments
Post a Comment