PHP while loop dynamic rowspan -


consider table example

enter image description here

using these table wanted print table these adding rowspan item id 1002.

enter image description here

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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -