How do I use a database on an HTML site?

Asked

Viewed 52,587 times

8

I am interested in making a site that will use a database, many told me they use Mysql to do this, but I have no knowledge about it, installation, use etc. I have knowledge in PHP, HTML, CSS and Javascript, I do not know if it interferes with something.

  • If you have knowledge with PHP, just follow the tips of the guys. If you want help using BD with PHP, check it out: http://www.w3schools.com/php/php_mysql_intro.asp This will help you. []’s

  • 4

    @Pauloviníciusmatos Do not recommend W3schools

6 answers

11

The question is quite broad, but basically you can use any database on a site because HTML is a markup language that has nothing to do with the database.

Developing Web has 3 basic parts:

  1. HTTP server: It is it that receives requests from users who are accessing the site, processes the information and returns an HTML;
  2. Processing Engine: It is called by the server to create an HTML dynamically. PHP is one of them, but there are others like Python, Ruby, Perl, Scala, Clojure, ASP.NET, Java, etc.
  3. Database: It is called by the processing engine of your website to gather information that is used by the processing engine to process the page that your user will see.

If you want to develop in PHP, there are several kits that bring together HTTP server, language engine and database. They are:

  • XAMPP (Apache + Mysql + PHP + Perl)
  • LAMP (Linux + Apache + Mysql + PHP)
  • WAMP (Windows + Apache + Mysql + PHP)
  • Easyphp (Windows + Apache + Mysql + PHP)

However, you don’t just need to use Apache as an HTTP server, PHP as a processing engine, or Mysql as a database. Today we have other alternatives, such as:

I strongly recommend leaving PHP and going to another language. There are several old ones on the Internet that support a number of PHP problems, like this one from the creator of Stackoverflow: http://www.codinghorror.com/blog/2008/05/php-sucks-but-it-doesnt-matter.html

  • 2

    Every language has its advantages and disadvantages. In the same way that there are a lot of problems with PHP, also exist in Java, Python, Ruby, etc., etc. About the article you posted, you must have escaped the conclusion: the language may not be a design primer, but it goes very well in what it proposes to solve.

  • 1

    I didn’t escape the conclusion. I just suggested leaving PHP and going to another language and bumped into an article because yesterday someone "got sad" with the comment and made an issue that is not pertinent. Opinion is part of the answer.

  • 1

    @Gypsy Rrisonmendez very good your answer is that level we want in Stackoverflow.

2

Maybe your knowledge in PHP is only theoretical and very basic, because most tutorials on the internet deal with PHP along with Mysql. I advise you to install a package like WAMP, which has already been mentioned.

After that you will configure Mysql and its tables. Use the following links:

Then start developing in PHP. Inside the PHP file you can put HTML code. This is a good introduction: http://aprenderphp.com.br/artigo/introducao-ao-php/

1

Mysql is recommended for a website, but there are other banks as well.

Install the XAMPP, or any other that has Mysql support, on your machine, with it you can have a localhost server, and use Mysql;

To make a simple php connection to your bank:

<?php    
//conexão com o servidor
$conect = mysql_connect("endereço_servidor", "usuario_do_banco_de_dados", "senha_banco_de_dados");

// Caso a conexão seja reprovada, exibe na tela uma mensagem de erro
if (!$conect) die ("<h1>Falha na coneco com o Banco de Dados!</h1>");

// Caso a conexão seja aprovada, então conecta o Banco de Dados.    
$db = mysql_select_db("nome_banco_de_dados");

/*Configurando este arquivo, depois é só você dar um include em suas paginas php, isto facilita muito, pois caso haja necessidade de mudar seu Banco de Dados
você altera somente um arquivo*/
?>

1

Depending on your goal, the Wordpress is a widely used platform, and uses the database. The good thing about Wordpress is that the use of the database is "behind the curtains", IE, you do not need to know how to create tables, guess how to make indexes, worry about the type of column you should put to a name field.

In the background, Wordpress uses Mysql, and PHP too, but saves you a lot of technical details, with many plugins and themes for customization.

0

You must install Apache, Mysql and PHP. One way to do this is to download XAMPP

The next step is choosing an IDE, your choice: sublime, phpstorm, Netbeans.

To enable PHP debugging you need to download and install Xdebug, which is nothing more than a DLL to add in PHP configuration.

to install Xdebug do the following:

Access the installation directory of php which comes in xamp, and edits the file php.ini.

Ex.: C:xampp\php\php.ini

Look for the line: ;zend_extension = "C:xamppphpextphp_xdebug.dll" and uncomment it (minus the semicolon), restart your Apache ready

botão de refresh

0

You need to install a program that will make your machine a local server, in case I recommend

  • XAMPP According to the site itself:

is completely free and easy to install the Apache distribution containing Mariadb

after this you must choose an ide an example is the

  • Eclipse A Free and Open Source IDE

For the Database is the

  • Mysql

After Create your database and your tables just make the connection by php

$servername = "NOME DO SERVIDOR";
$username = "NOME DO USUÀRIO";
$password = "SENHA";
$dbname = "NOME DO BANCO";
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($con->connect_error) {
	die("Connection failed: " . $con->connect_error);
}

Browser other questions tagged

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