K
K
konohovec2020-05-15 13:13:48
PHP
konohovec, 2020-05-15 13:13:48

Outputting data from the database to the site page. How to do?

I have a MySql database. I removed all the data in the code)) Here is a code that displays arrays of data from a database of this type
Array ( [ID] => 1 [Diametr] => 14 [Width] => 555 [Height] => 666 [Marka] => kama )
Array ( [ID] => 2 [Diametr] => 22 [Width] => 3 [Height] => 44 [Marka] => cordiant ) Tell me
how we can display this data, for example

  1. Diameter: (HERE YOU NEED TO GET THE DIAMETER VALUE FROM THE DB
  2. Height: (...)
  3. Width: (...)
  4. Brand: (...)

I am a complete newbie to PHP and Databases. Thanks in advance!
<?php
  $mysqli = @new mysqli('localhost', 'name', 'pass', 'bd');
  $result_set = $mysqli->query('SELECT * FROM autoobuv_spb');
  while ($row = $result_set->fetch_assoc()) {
    print_r($row);
    echo "<br />";
  }
  $result_set->close();
  $mysqli->close();
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jonh Doe, 2020-05-15
@konohovec

$mysqli = @new mysqli('localhost', 'name', 'pass', 'bd');
  $result_set = $mysqli->query('SELECT * FROM autoobuv_spb');
  while ($row = $result_set->fetch_assoc()) {
    foreach($row as $v=>$k) {
        echo $k.': '.$v.'<br>';
    }   
  }
  $result_set->close();
  $mysqli->close();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question