php - How to get output in table fromat in html page , using phpscript and extracted from mysql database? -


i trying fetch data mysql database , print on new web page. need display output in table format.
below php script, me out so.
in advance.

<?php     $userinput = $_post['sample_name'];     $servername = "localhost";     $username = "root";     $password = "";     $dbname = "processtrackingsystem";      // create connection     $conn = new mysqli($servername, $username, $password, $dbname);     // check connection     if ($conn->connect_errno) {         printf("connect failed: %s\n", $conn->connect_error);         exit();     }      $result = mysqli_query($conn, "select * processtrackingsystem.processdetails                                    sample_name = '$userinput'") or die(mysqli_error($conn));      while ($row=mysqli_fetch_assoc($result))     {         printf("sample_name:->");         printf($row['sample_name']);         printf("<br>\r\n");         printf("<br>\r\n");         printf("so_id:->");         printf($row['so_id']);         printf("<br>\r\n");         printf("<br>\r\n");     }      mysqli_free_result($result);     $conn->close(); ?> 

i need output in tabular format.

you can create table following way.

echo "<table border='1'>     <tr>         <th>sample_name</th>         <th>so_id</th>     </tr>";     while($row = mysqli_fetch_assoc($result))    {        echo "<tr>";            echo "<td>" . $row['sample_name'] . "</td>";            echo "<td>" . $row['so_id'] . "</td>";        echo "</tr>";    }    echo "</table>"; 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -