php table form

Solutions on MaxInterview for php table form by the best coders in the world

showing results for - "php table form"
Michelle
22 Sep 2018
1<html>
2<body>
3<?php 
4$username = "username"; 
5$password = "password"; 
6$database = "your_database"; 
7$mysqli = new mysqli("localhost", $username, $password, $database); 
8$query = "SELECT * FROM table_name";
9
10
11echo '<table border="0" cellspacing="2" cellpadding="2"> 
12      <tr> 
13          <td> <font face="Arial">Value1</font> </td> 
14          <td> <font face="Arial">Value2</font> </td> 
15          <td> <font face="Arial">Value3</font> </td> 
16          <td> <font face="Arial">Value4</font> </td> 
17          <td> <font face="Arial">Value5</font> </td> 
18      </tr>';
19
20if ($result = $mysqli->query($query)) {
21    while ($row = $result->fetch_assoc()) {
22        $field1name = $row["col1"];
23        $field2name = $row["col2"];
24        $field3name = $row["col3"];
25        $field4name = $row["col4"];
26        $field5name = $row["col5"]; 
27
28        echo '<tr> 
29                  <td>'.$field1name.'</td> 
30                  <td>'.$field2name.'</td> 
31                  <td>'.$field3name.'</td> 
32                  <td>'.$field4name.'</td> 
33                  <td>'.$field5name.'</td> 
34              </tr>';
35    }
36    $result->free();
37} 
38?>
39</body>
40</html>