harisx

Untitled

Feb 16th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. $conn = new mysqli($servername, $username, $password, $dbname);
  2. if ($conn->connect_error) {
  3.     die("Connection failed: " . $conn->connect_error);
  4. }
  5.  
  6. $sql = "SELECT id, data FROM table";
  7. $result = $conn->query($sql);
  8.  
  9. if ($result->num_rows > 0) {
  10.     echo "<table>";
  11.     echo "<thead>";
  12.     echo "<tr>";
  13.     echo "<th>ID</th>";
  14.     echo "<th>name</th>";
  15.     echo "</thead>";
  16.     echo "<tbody>";
  17.  
  18.     while($row = $result->fetch_assoc()) {
  19.  
  20.         echo "<tr>";
  21.         echo "<td>".$row["id"]."</td>";
  22.  
  23.         $array = $row["data"];
  24.         $array = json_decode($array);
  25.  
  26.         echo "<td>".$array[1]->value."</td>";
  27.     }
  28.     echo "</tbody>";
  29.     echo "</table>";
  30. } else {
  31.     echo "0 results";
  32. }
  33. $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment