This project is a simple web-based "Random Quote Generator" that fetches a random quote from a MySQL database. The application is built using HTML, CSS, JavaScript, PHP, and MySQL, and runs locally using XAMPP.
-
Install XAMPP:
- Download and install XAMPP.
- Launch XAMPP and start both Apache and MySQL.
-
Create MySQL Database and Table:
- Open phpMyAdmin in your browser.
- Create a new database named
ai_quotes. - Inside the
ai_quotesdatabase, create a table namedquoteswith the following fields:id(INT, AUTO_INCREMENT, PRIMARY KEY)quote_text(TEXT)author(VARCHAR(100))
-
Add Quotes to the Table:
- Manually add a few quotes to the
quotestable through phpMyAdmin.
- Manually add a few quotes to the
-
Place the Files in XAMPP's htdocs Directory:
- Place your project folder (e.g.,
quote-generator) inside theC:\xampp\htdocs\directory. - Your folder structure should look like this:
C:\xampp\htdocs\quote-generator\ ├── index.html ├── styles.css ├── app.js └── server\ └── fetch_quote.php
- Place your project folder (e.g.,
-
Access the App:
- Open your browser and go to
http://localhost/quote-generator/to view the app.
- Open your browser and go to
- XAMPP (Apache & MySQL): Local server setup.
- HTML: Structure of the page.
- CSS: Page styling.
- JavaScript: Fetching data from PHP using AJAX.
- PHP & MySQL: Backend to retrieve random quotes from the database.
- Click the "Get Quote" button to fetch and display a random quote from the MySQL database.
- No quote displayed: Ensure that the MySQL server is running and the
quotestable has data. - Connection issues: Verify your MySQL credentials in the PHP file and ensure that XAMPP is running.
This project is open source under the MIT License.
