Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

?
Lv 5

Query and display results from database on html page?

Hello,

I'm working on a personal webpage with very limited knowledge of html so I apologize for the simplicity of the question.

I would like to search and display results from a database on my html page.

The database will only have 3 columns; column 1 will have search terms, and column 2&3 will hold the data to be displayed on the webpage when the respective search term from column 1 is searched.

Ex) 1: Product name 2: Price 3: Quantity available

I am in no way familiar with using databases like SQL, so based on my research, I'm thinking excel or SQLite will be the easiest for me to learn and implement.

I can't seem to find information or tutorials on the web regarding using SQLite the way I want to. Is my understanding of SQLite incorrect?

What method might be the easiest for me to implement my search function? Ideally, I would like my database to be scaleable as well.

Any help will be greatly appreciated.

Thank you in advance.

1 Answer

Relevance
  • Chris
    Lv 7
    4 years ago
    Favorite Answer

    You are missing a key component: server-side scripting. A typical language you can use for that is PHP.

    The problem is that despite many people believing otherwise, HTML is not a programming language. It cannot query a database. HTML is basically just a way to format text nicely, if you will. You can use it to make parts of your text clickable, or to arrange it into a submittable form. But HTML cannot actually *do* anything.

    To implement a database in your website, whether SQL, SQLite or some other one, you need a webserver that can do more than just send back HTML documents; you need one that can actually run scripts.

    The idea is that upon a request by the user (i.e. clicking a link or sending a form), instead of simply sending back a static HTML file, the server will run a script. The script does stuff on the server (like for instance read from a database), then composes HTML code on the fly. This HTML is sent back to the browser.

    PHP is made for beginners, and using it is pretty basic:

    <p>This is HTML.</p>

    <p><?php

    // in here is php code, a script that is being processed on the server

    echo 3 * 5;

    ?></p>

    If you save the above as index.php in a php server's document root and visit the server in a browser, the script will run and cause the following HTML to be transmitted:

    <p>This is HTML.</p>

    <p>15</p>

    The php server transmits everything outside php tags as-is, but runs the code inside them. I'm using the echo command to print the result of a simply calculation, which ends up in between the static HTML.

    To develop the website on your own computer you need to set up a local webserver and database server. Here's a free all-in-one package: https://www.apachefriends.org/index.html

Still have questions? Get your answers by asking now.