NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
PhpEd Debugger show variable empty value - WHY? pls help


Joined: 07 Jan 2011
Posts: 2
Reply with quote
Code:
<?php

// show SELECT result as HTML table
function show_table($result) {
  if(!$result) {
    echo "<p>No valid query result.</p>\n";
    return;
  }

  if($result->num_rows>0 && $result->field_count>0) {
    echo "<table>";

    // column headings
    echo "<tr>";
    // tworzy zmienn? $meta ktora sie potem juz nie zmienia
    foreach($result->fetch_fields() as $meta)
      printf("<th>%s</th>", htmlspecialchars($meta->name));
    echo "</tr>\n";

    // content
    // row fetch row
    // tworzy $row
    while($row = $result->fetch_row()) {
      echo "<tr>";
      // wartosc z $row idzie do $col
      foreach($row as $col)
        printf("<td>%s</td>", htmlspecialchars($col));
      echo "</tr>\n";
    }
    echo "</table>\n";
  }
}

require_once 'password.php';

// connect to MySQL
$mysqli = new mysqli($mysqlhost, $mysqluser, $mysqlpasswd, $mysqldb);
if(mysqli_connect_errno()) {
  echo "<p>Sorry, no connection! ", mysqli_connect_error(), "</p>\n";
  exit();
}

// show SELECT result with show_table
//$result przestaje byc NULL - przyjmuje pust? wartosc
if($result = $mysqli->query("SELECT * FROM titles")) {
  show_table($result);
  $result->close();
}

// disconnect
$mysqli->close();

?>
</body></html>

<?php


?>
View user's profileFind all posts by easyriderSend private message
PhpEd Debugger show variable empty value - WHY? pls help
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic