How do I use a database in an HTML site?

8

I am interested in making a website that will use database, many told me that if you use MySQL to do this, however 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 anything.

    
asked by anonymous 04.02.2014 / 19:57

6 answers

9

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

Developing Web has 3 basic parts:

  • HTTP Server : It receives requests from users accessing the site, processes information and returns HTML;
  • Processing Engine : It is called by the server to dynamically create HTML. PHP is one of them, but there are others like Python, Ruby, Perl, Scala, Clojure, ASP.NET, Java, etc.
  • Database : It is called by the processing engine of your site 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 do not have 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 going out of PHP and going into another language. There are several old ones on the Internet that support a number of PHP problems, such as this one from the StackOverflow creator: link

        
    04.02.2014 / 20:49
    2

    Maybe your knowledge of PHP is only theoretical and very basic, since most of the tutorials on the internet treat PHP together with MySQL. I advise you to install a package like WAMP, which has already been quoted.

    After this you will configure MySQL and its tables. Use the following links:

    Then start developing in PHP. Inside the PHP file you can place HTML code. This is a good introduction: link

    • You can download wamp here: link
    • You have several code samples here: link or here: link or here: link
    • Youtube also has lots of video lessons.
    04.02.2014 / 20:11
    1

    Depending on your goal, Wordpress is a widely used platform, and uses the database. The good thing about Wordpress is that database usage is "behind the scenes," meaning you do not have to know how to create tables, guess how to index, worry about what kind of column you should put into a field

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

        
    05.02.2014 / 05:22
    1

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

    Install XAMPP , or anyone else who 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*/
    ?>
    
        
    04.02.2014 / 20:07
    0

    You should install Apache, MySQL, and PHP. One way to do this is to download XAMPP

    The next step is to choose an IDE, it's your choice: sublime , phpstorm , NetBeans .

    To enable PHP debugging, you need to download and install XDebug, which is nothing more than a DLL to append to the PHP configuration.

    To install XDebug do the following:

    Access the php installation directory that comes with xamp, and edit the php.ini file.

    Eg: C:xampp\php\php.ini

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

        
    04.02.2014 / 20:47
    0

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

    • XAMPP According to the website itself:
      

    It's completely free and easy to install the Apache distribution containing MariaDB

    After this you should choose an ide an example is the

    • Eclipse A Free IDE and Open source

    For the Database is the

    • MySql

    After creating 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);
    }
        
    10.05.2016 / 15:19