mysql - How to automatically design a dynamic table when fetching row (PHP /MySQLi) -


i'd design dynamic table when fetching row in php/mysql. please see attached image of example.

see code below, works vertical bar in middle doesn't seems fit well.

for ($i = 0;$i<$result->num_rows;$i++){ $row = $result->fetch_array(mysqli_num);     //echo "* ".$row["0"]."<br>";   // work great     //echo "* " .$row["0"] .$row["1"] ."<br>";     echo "| " .$row["1"] ."&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" ." | " ."&nbsp&nbsp&nbsp" .$row["2"] ."<br>"; } 

image of code result

what want do:

image of want do

that example of how echo html tables php code

echo "<table><thead></thead><tbody>" ($i = 0;$i<$result->num_rows;$i++){     $row = $result->fetch_array(mysqli_num);     echo "<tr>".          "<td>{$row["0"]}</td>".          "<td>{$row["1"]}</td>".          "<td>{$row["2"]}</td>".          "</tr>\n"; }  echo "</tbody></table>" 

css

td{     padding: 3px; /*add space directions (top, right,bottom, left)*/     padding-left: 6px; /*add space left side only*/ } 

put css in css files of html document (it applied td elements in document). or -which not recommended- inline-css this

  echo "<tr>".          "<td style='padding-left:6px'>{$row["0"]}</td>".          "<td style='padding-left:6px'>{$row["1"]}</td>".          "<td style='padding-left:6px'>{$row["2"]}</td>".          "</tr>\n";     

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -