Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9279609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:40:34+00:00 2026-06-18T17:40:34+00:00

How to connect a html page to MySQL for example, i want to use

  • 0

How to connect a html page to MySQL for example, i want to use <?php echo $_POST['username']; ?> in a HTML file. How do i connect to MySQL.
I have tryed this:

<?php
$con=mysql_connect("HOST", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE"); 
?>

But it did not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:40:35+00:00Added an answer on June 18, 2026 at 5:40 pm

    HTML are markup languages, basically they are set of tags like <html>, <body>, which is used to present a website using css, and javascript as a whole. All these, happen in the clients system or the user you will be browsing the website.

    Now, Connecting to a database, happens on whole another level. It happens on server, which is where the website is hosted.

    So, in order to connect to the database and perform various data related actions, you have to use server-side scripts, like php, jsp, asp.net etc.

    Now, lets see a snippet of connection using MYSQLi Extension of PHP

    $db = mysqli_connect('hostname','username','password','databasename');
    

    This single line code, is enough to get you started, you can mix such code, combined with HTML tags to create a HTML page, which is show data based pages. For example:

    <?php
        $db = mysqli_connect('hostname','username','password','databasename');
    ?>
    <html>
        <body>
              <?php
                    $query = "SELECT * FROM `mytable`;";
                    $result = mysqli_query($db, $query);
                    while($row = mysqli_fetch_assoc($result)) {
                          // Display your datas on the page
                    }
              ?>
        </body>
    </html>
    

    In order to insert new data into the database, you can use phpMyAdmin or write a INSERT query and execute them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in a .html.erb file: <script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script> <script> FB.Event.subscribe('edge.create', function(response) {
I have implemented Facebook Connect into a HTML page exactly as the tutorial explains
I have a box built via html borders. I want to connect the bottom
I have a simple html page below calling a global.js file the global.js file
I have a html page that calls a php object to get some data
I have a php file that contains a HTML form, then PHP logic, then
For example, testing the code: <HTML> <BODY> <?php $connect = mysql_connect(localhost, root, password) or
I have a php file which connects to a MySql db and read the
I have this HTML form page: form1.html <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd
I have simple html page with php as given below: <!DOCTYPE html PUBLIC -//W3C//DTD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.