PHP Homework Help | Practice Sample Set
- realcode4you
- Sep 23, 2021
- 5 min read

Requirement Details
Let there be database tables.
Rely on XAMPP and create the database table locally. You need to create a database called “assignment8” programmatically. Please submit the “create database” and “create table” sql commands, either through your init.php or if done separately, please submit it through a .sql file. In case you have a .sql file, please make sure that you are calling it from your .php file. I will need only to run your index.php and it should run the init.php which, if required, would run the .sql file.
Now that you have the details on how to connect to the database, you need to create a table that replicate the input.csv structure from last assignment; i.e. every column in that table needs to be translated into a column in the database.
Within your program, you need to open the input.csv file, read its content and every row in this csv table needs to be populated inside the database table you have created.
So, in summary, here is what you need to do:
Create a database called “assignment8”
Create a table named “Items”
Within this table, create the following columns
Structure for Items Table
Name Type Length/Values Default Attributes
ID INT 6 NONE Unsigned, auto_increment, primary key
Name VARCHAR 40 NONE
Type VARCHAR 40 NONE
Make VARCHAR 40 NONE
Model VARCHAR 40 NONE
3
Brand
VARCHAR
40
NONE
Description
VARCHAR
60
NONE
- Read the content of “input.csv” file and populate with it the rows of “items” table
- You need to create these columns from within a php page and for this reason, you need to create a file called init.php and use the examples in the slides or any other resource provided, to create the columns
o You run this file once only, since the database management system (DBMS) will create them once and they will be there for you anytime you access them
o Within your init.php, you need to insert the rows for each entry you have created in input.csv
- So, in summary, init.php will create the database, connect to it, create the table with the columns list provided above and populate this table with records read from the content of the file “input.csv”.
- You can use the default template provided for “input.csv” or even better, update this content with what you have been building through the whole course in term of services or products.
o One thing to pay attention to is that you do not need to insert the “item #” value from input.csv but you need to rely on the DBMS to auto-generate this field for you
- Now that we got the table populated, you need to go back to index.php and change your php code to read input from the database by querying it using a select statement
- The select statement needs to query the table created using the filtering input the user enters
o Select records from the table we are working with, where the name of the item is similar to <value entered by the user>
Dataset You can download form here
Hint and reference code
<!DOCTYPE html>
<html lang="en">
<?php include ('init.php') ; ?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<form action="index.php" method="post" enctype="multipart/form-data">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body onload="pageLoadingTime()">
<?php
class Item {
public $itemNumber;
public $name;
public $type;
public $make;
public $model;
public $brand;
public $description;
function __construct($itemNumber, $name, $type, $make, $model, $brand, $description){
$this->itemNumber = $itemNumber;
$this->name = $name;
$this->type = $type;
$this->make = $make;
$this->model = $model;
$this->brand = $brand;
$this->description = $description;
}
function display(){
return "Item Number : ".$this->itemNumber."<br>Item Name : ".$this->name."<br>Item Type : ".$this->type."<br>Make : ".$this->make."<br>Model : ".$this->model."<br>Brand : ".$this->brand."<br>Description: ".$this->description."<br>";
}
}
$inFile = fopen("input.csv","r") or die("File cannot be opened!!");
$line = " ";
$line_number = 1;
$content_of_line;
$items;
$i=0;
while(!feof($inFile)){
$line = fgets($inFile);
if (empty($line)) {
continue;
}
$words = explode(",",$line);
if (!is_numeric($words[0])) {
continue;
$stmt = $conn->prepare("INSERT INTO items (name, type, brand, model, make, description) values (?,?,?,?,?,?);");
$stmt->bind_param("ssssss", $words[1],$words[2],$words[3],$words[4],$words[5],$words[6])
$stmt->execute();
}
fclose($inFile);
?>
<header>
<div class="navbar">
<a class="active" href="#"><i class="fa fa-fw fa-home"></i> Home</a>
<div class="dropdown">
<button class="dropbtn">Products
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="currency.php">Currency Exchange</a>
<a href="">Service 2</a>
</div>
</div>
<div class="dropdown">
<button onclick="location.href='contact.html'" class="dropbtn">Contact Us
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href=""><img class="countryFlag" src="img/france.png" alt="france">Contactez-nous</a>
<a href=""><img class="countryFlag" src="img/ukraine.png" alt="ukraine">Зв'затися з нами</a>
</div>
</div>
<a href="aboutme.html">About</a>
</div>
</header>
<div class="container">
<p class="pageLoading"></p>
<p class="bookHeader">PLASTIC SURGERY PROCEDURES</p>
<div class="about_product">
<h2>
Find most needed plastic surgery procedures.
</h2>
</div>
<p class="searchText">SEARCH FOR A PROCEDURE</p>
<div class="procedureSearch">
<input type="text" id="searchInput" onkeyup='search(<?php echo json_encode($items) ?>)' placeholder="Search for procedure..">
</div>
<ul id="myUL">
<li style="display: none;"><a href="#">A Journey to the Center of the Earth</a></li>
<li style="display: none;"><a href="#">The War of the Worlds</a></li>
<li style="display: none;"><a href="#">Brave New World</a></li>
<li style="display: none;"><a href="#">When Worlds Collide</a></li>
<li style="display: none;"><a href="#">Odd John</a></li>
<li style="display: none;"><a href="#">Nineteen Eighty-Four</a></li>
<li style="display: none;"><a href="#">Earth Abides</a></li>
<li style="display: none;"><a href="#">Foundation</a></li>
<li style="display: none;"><a href="#">The Illustrated Man</a></li>
<li style="display: none;"><a href="#">The Demolished Man</a></li>
<li style="display: none;"><a href="#">Ring Around the Sun</a></li>
<li style="display: none;"><a href="#">Mission of Gravity</a></li>
<li style="display: none;"><a href="#">The Long Tomorrow</a></li>
<li style="display: none;"><a href="#">The Chrysalids</a></li>
<li style="display: none;"><a href="#">The Death of Grass or No Blade of Grass</a></li>
<li style="display: none;"><a href="#">Starship Troopers</a></li>
<li style="display: none;"><a href="#">The Sirens of Titan</a></li>
<li style="display: none;"><a href="#">Alas, Babylon</a></li>
<li style="display: none;"><a href="#">A Canticle for Leibowitz</a></li>
<li style="display: none;"><a href="#">Venus Plus X</a></li>
<li style="display: none;"><a href="#">Solaris</a></li>
<li style="display: none;"><a href="#">The Drowned World</a></li>
<li style="display: none;"><a href="#">Hothouse</a></li>
<li style="display: none;"><a href="#">A Wrinkle in Time</a></li>
<li style="display: none;"><a href="#">Dune</a></li>
<li style="display: none;"><a href="#">Make Room! Make Room!</a></li>
<li style="display: none;"><a href="#">Logan's Run</a></li>
<li style="display: none;"><a href="#">Do Androids Dream of Electric Sheep?</a></li>
<li style="display: none;"><a href="#">The Left Hand of Darkness</a></li>
<li style="display: none;"><a href="#">Behold the Man</a></li>
<li style="display: none;"><a href="#">Ringworld</a></li>
<li style="display: none;"><a href="#">Rendezvous with Rama</a></li>
<li style="display: none;"><a href="#">Roadside Picnic / Tale of the Troika</a></li>
<li style="display: none;"><a href="#">The Female Man</a></li>
<li style="display: none;"><a href="#">Man Plus</a></li>
<li style="display: none;"><a href="#">The Stand</a></li>
<li style="display: none;"><a href="#">The Hitchhiker's Guide to the Galaxy</a></li>
<li style="display: none;"><a href="#">Nor Crystal Tears</a></li>
<li style="display: none;"><a href="#">Ender's Game</a></li>
<li style="display: none;"><a href="#">Consider Phlebas</a></li>
<li style="display: none;"><a href="#">Falling Free</a></li>
<li style="display: none;"><a href="#">Hyperion</a></li>
<li style="display: none;"><a href="#">Red Mars</a></li>
<li style="display: none;"><a href="#">Ribofunk</a></li>
<li style="display: none;"><a href="#">Cryptonomicon</a></li>
<li style="display: none;"><a href="#">Uglies</a></li>
<li style="display: none;"><a href="#">Old Man's War</a></li>
<li style="display: none;"><a href="#">Little Brother</a></li>
<li style="display: none;"><a href="#">Acme Novelty Library #19</a></li>
<li style="display: none;"><a href="#">Embassytown</a></li>
</ul>
<div id="resultsContainer">
</div>
</div>
<script src="function.js"></script>
</body>
</html>If you need any programming assignment help in PHP programming, PHP project or PHP homework or need solution of above problem then we are ready to help you.
Send your request at realcode4you@gmail.com and get instant help with an affordable price.
We are always focus to delivered unique or without plagiarism code which is written by our highly educated professional which provide well structured code within your given time frame.
If you are looking other programming language help like C, C++, Java, Python, PHP, Asp.Net, NodeJs, ReactJs, etc. with the different types of databases like MySQL, MongoDB, SQL Server, Oracle, etc. then also contact us.



GG88 mình mới ghé thử vì thấy bạn bè nhắc hoài, chủ yếu vào xem giao diện chứ không có ngồi “cày” nội dung. Cảm giác đầu tiên là trang chia khối nhìn gọn, kéo xuống không bị rối mắt, tiêu đề nổi nên lướt nhanh vẫn nắm được đang có gì. Mình có bắt gặp một bài kiểu giải thích “bao lô là gì”, đọc tiêu đề là hiểu ngay hướng bài viết, hợp cho ai chỉ muốn xem sơ sơ. Menu đặt khá dễ thấy, chuyển qua lại mấy mục cũng trơn tru, không phải bấm mò. Nói chung nhìn thân thiện, không bị nhồi chữ, các bài được xếp theo dạng danh sách với heading rõ ràng…
O8 mình thấy bạn bè nhắc nhiều quá nên cũng ghé thử cho biết, kiểu vào xem giao diện thôi chứ chưa làm gì sâu. Lướt vài phút là thấy trang họ chia nội dung theo từng khối khá rõ, nhìn phát biết đang ở phần nào, không bị rối mắt. Mình để ý ngay đoạn giới thiệu nguồn gốc với mấy giấy phép quốc tế (PAGCOR, Isle of Man, Curacao eGaming) được đặt khá nổi ở phần tổng quan, nên ai quan tâm độ minh bạch chắc sẽ thấy liền. Menu cũng gọn, bấm qua lại không phải mò lâu, chữ tiêu đề to vừa đủ nên đọc lướt vẫn hiểu. Nói chung cảm giác “dễ thở” hơn mình…
GO88 dạo này thấy nhiều người nhắc nên mình cũng bấm vào xem thử cho biết, kiểu lướt qua giao diện thôi chứ không làm gì sâu. Ấn tượng đầu là trang nhìn khá gọn, chữ không bị dày đặc nên đọc đỡ mệt. Mình kéo xuống một lúc vẫn thấy dễ theo dõi vì họ chia nội dung thành từng khối rõ ràng, nhìn phát biết đoạn nào đang nói gì. Có lướt ngang thấy họ có nhắc Tài Xỉu với Nổ Hũ nên đoán là dạng cổng game, nhưng cách trình bày không bị “ồn” quá. Mình thích nhất mấy cái tiêu đề họ làm nổi, kiểu đọc lướt vẫn bắt được ý chính, và các heading tách…
33win dạo này thấy mọi người nói hoài nên mình tò mò vào nghía thử cho biết chứ cũng không chơi gì. Vào cái là thấy giao diện khá sáng sủa, nhìn không bị ngợp như nhiều trang khác. Mình để ý họ chia nội dung thành từng khối rõ ràng, kiểu lướt xuống là biết đang xem phần nào, không phải căng mắt tìm. Mấy chỗ thông tin họ trình bày dạng bảng cột nên đọc nhanh, nhìn phát là nắm được ý chính, không bị rối chữ. Menu cũng nằm chỗ dễ thấy, bấm qua lại giữa các mục thấy mượt, không phải load lại lằng nhằng. Nói chung chỉ xem vài phút thôi mà quen tay vì…
Xổ Số DN88 hôm bữa mình lướt thấy nhắc nhiều nên bấm vào coi thử cho biết, kiểu xem giao diện có dễ dùng không thôi. Cảm giác đầu tiên là trang làm khá sạch, nhìn trên điện thoại không bị rối mắt, mấy mục chính để ngay ngắn nên tìm thông tin nhanh. Mình có nghía qua phần nạp rút, họ ghi xử lý siêu tốc và cách trình bày cũng rõ ràng, nhìn phát hiểu chứ không phải mò từng dòng. Không biết do mình ít bấm hay sao nhưng chuyển qua lại thấy mượt, không bị giật lag. Nói chung mình thích kiểu tối giản như vậy, đỡ loạn. Kéo xuống là thấy các khối nội dung…