Database data for web page

Asked

Viewed 31 times

1

I needed help because I wanted to send the data from my database to the website

BASE FIELDS: Id_Produto, NomeProduto, PrecoProduto,DescricaoProduto, QuantidadeProduto, CategoriaProduto -

TABLE NAME: produtos

The page I’m creating is in php so I can access information from the database.

But I can’t make the code

I’m using `

      mysqli_connect('localhost', 'root', '', 'pap') or die (mysqli_error ());



$strSQL = "SELECT * FROM produtos";

$rs = mysqli_query($strSQL);


while($row = mysqli_fetch_array($rs)) {

echo $row['NomeProduto'] . "<br />";
echo $row['DescricaoProduto'] . "<br />";

  }

// Encerra a conexão
mysqli_close();  ?>

`

1 answer

1


Try it this way:

<?php
 $con=mysqli_connect('localhost', 'root', '', 'pap') or die (mysqli_error ());



$strSQL = "SELECT * FROM produtos";

$rs = mysqli_query($con,$strSQL);


while($row = mysqli_fetch_array($rs)) {
echo" ".$row['NomeProduto']."";
echo" ".$row['DescricaoProduto']."";
  }

// Encerra a conexão
mysqli_close();  ?>

  • no database data is shown, but this : ("; echo $Row['Descricaoproduct'] . " "; } // Terminates connection mysqli_close(); ?>)

  • @Joségomes try now

  • continues to make the same mistake

  • try now @Joségomes

  • is already sending the data, but keeps this icon -> and an error still 'Warning: mysqli_close() expects Exactly 1 Parameter, 0 Given in C: xampp htdocs Site pagina_produto.php on line 459' which has the following code - mysqli_close(); ?>

  • deletes mysqli_close(); no need; ?>

  • and as for the points of ? knows how to solve?

  • adds this at the beginning of the code, following <html> inside <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

  • had it already and it doesn’t work

  • and if so: <meta charset="utf-8">

  • also does not work

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.