• Javascript
  • Python
  • Go

Upcoming Birthday Selection in SQL

HTML tags formatting is a powerful tool for creating visually appealing and structured content. In this article, we will explore the use of ...

HTML tags formatting is a powerful tool for creating visually appealing and structured content. In this article, we will explore the use of HTML tags to showcase the upcoming birthday selection in SQL.

Birthdays are special occasions that are celebrated by people all around the world. As a database administrator, it is important to be able to efficiently manage and retrieve data related to birthdays. SQL (Structured Query Language) is a programming language that is widely used for managing and querying databases. With the use of SQL, we can easily retrieve data related to birthdays from our database and display it in a user-friendly format.

To start off, let's create a table in our database to store information about birthdays. We will name the table "birthdays" and it will have the following columns: "name", "date_of_birth", "age", and "upcoming_birthday". Now, let's insert some sample data into our table:

| Name | Date of Birth | Age | Upcoming Birthday |

|-------------|---------------|-----|--------------------|

| John Smith | 1990-05-03 | 30 | 2021-05-03 |

| Sarah Jones | 1985-10-12 | 35 | 2021-10-12 |

| David Lee | 1988-12-25 | 32 | 2021-12-25 |

As you can see, we have the names, dates of birth, ages, and upcoming birthdays of three individuals in our table. Now, let's use SQL to retrieve this data and display it in a formatted manner using HTML tags.

First, we will use the SELECT statement to retrieve the data from our table:

SELECT * FROM birthdays;

This will retrieve all the data from the "birthdays" table. Next, we will use the WHERE clause to filter the data based on the upcoming birthday. We want to display only the data where the upcoming birthday is in the current year. So our query will look like this:

SELECT * FROM birthdays

WHERE upcoming_birthday BETWEEN '2021-01-01' AND '2021-12-31';

This will retrieve all the data from our table where the upcoming birthday falls within the current year. Now, let's use HTML tags to display this data in a formatted manner.

We will start by using the <table> tag to create a table for our data. Inside the <table> tag, we will use the <tr> tag to create a row and the <th> tag to create column headers. Our code will look like this:

<table>

<tr>

<th>Name</th>

<th>Date of Birth</th>

<th>Age</th>

<th>Upcoming Birthday</th>

</tr>

</table>

Next, we will use a loop to iterate through the data retrieved from our database and use the <td> tag to create table cells for each column. Our code will look like this:

<table>

<tr>

<th>Name</th>

<th>Date of Birth</th>

<th>Age</th>

<th>Upcoming Birthday</th>

</tr>

<?php

// code to connect to the database and retrieve data

while($row = mysqli_fetch_assoc($result)) {

echo "<tr>";

echo "<td>" . $row['name'] . "</td>";

echo "<td>" . $row['date_of_birth'] . "</td>";

echo "<td>" . $row['age'] . "</td>";

echo "<td>" . $row['upcoming_birthday'] . "</td>";

echo "</tr>";

}

?>

</table>

This code will display the data in a tabular format with each row containing the name, date of birth, age, and upcoming birthday of an individual.

John Smith | 1990-05-03 | 30 | 2021-05-03

Sarah Jones | 1985-10-12 | 35 | 2021-10-12

David Lee | 1988-12-25 | 32 | 2021-12-25

To make the table more visually appealing, we can use the <style> tag to add some CSS styling to our table. We can change the font, size, and color of the table headers and cells to make them stand out. We can also add a border to the table to make it look more structured.

<table style="font-family: Arial, sans-serif; border-collapse: collapse;">

<tr>

<th style="border: 1px solid #dddddd; text-align: left; padding: 8px;">Name</th>

<th style="border: 1px solid #dddddd; text-align

Related Articles