Question
Milestone 2: create and populate a database table for baby names 6. Download the file containing the 1000 most popular baby names in 2014, according
Milestone 2: create and populate a database table for baby names 6. Download the file containing the 1000 most popular baby names in 2014, according to the Social Security Administration office: https://www.ssa.gov/oact/babynames/names.zip. 7. Expand the zip file and look for the file named yob2014.txt. 8. Upload that file to your area on the server. 9. Write a PHP script to: o Connect to the database o Create a table (BABYNAMES) for storing the most popular baby names o Populate the table using the raw content from yob2014.txt. o Display the tables contents on a web page.
Milestone 3: implement basic functionality 10. Write a PHP script that allows users to vote on their favorite boy/girl baby name. Basically it should: o Display a form containing: a way to select boy or girl, a text input for typing in the name, and a Submit button. o Once the Submit button is pressed, record the users input into a table (separate from BABYNAMES), which you use to keep track of the votes received so far. o Display the most popular names so far (in decreasing order by number of votes). See https://www.ssa.gov/oact/babynames/ for an example of such table (limited to the top 10 baby names).
db_connect.php
// You will need to require this file on EVERY php file that uses the database. // Be sure to use $db->close(); at the end of each php file that includes this!
$dbhost = 'localhost'; // Most likely will not need to be changed $dbname = ''; $dbuser = ''; $dbpass = '';
$db = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if($db->connect_errno > 0) { die('Unable to connect to database [' . $db->connect_error . ']'); }
index.php
Database Table Test
Step One Creating the table
query($createStmt)) { echo '
Step Two Inserting into the table
query($insertStmt)) { echo '
Step Three Retrieving the rows
query($selectStmt); if($result->num_rows > 0) { echo 'id: ' . $row["id"] . ' - value: ' . $row["value"] . '
' . PHP_EOL; } echo '
Step Four Dropping the table
query($dropStmt)) { echo '
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started