top of page

PHP Homework Help | Practice Sample Set

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.


78 Comments


bj38 mình ghé vào thì gặp thông báo lỗi nên chưa xem được nội dung bên trong. Ban đầu cứ tưởng mạng nhà mình chập chờn, nhưng đọc phần giải thích mới biết kết nối giữa trang và máy chủ đang có vấn đề. Mình thấy thông báo như vậy khá dễ hiểu, không cần rành kỹ thuật vẫn nắm được lý do trang chưa hiện lên. Còn giao diện chính ra sao thì mình chưa thấy nên cũng không có gì để kể thêm, đợi lúc truy cập được rồi mới biết. Dù chỉ là trang báo lỗi, phần chữ đang hiện cũng đủ để mình hiểu tình hình, không phải ngồi đoán xem có chuyện gì. Hai mục…

Like

E39 mình vừa lướt qua một chút lúc rảnh, chưa xem được bao nhiêu nên chỉ kể vài thứ đập vào mắt thôi. Bình thường vào trang lạ là mình hay bấm tới bấm lui vì chưa quen chỗ nào với chỗ nào, lần này thì đỡ hơn mình nghĩ. Các nhóm nội dung nhìn khá tách bạch, lướt sơ cũng biết mình đang ở phần nào mà không cần đọc hết chữ trên màn hình. Mình thích điểm đó vì thường chỉ tranh thủ xem bằng điện thoại vài phút, đang xem mà phải dò đường nhiều quá là dễ mất hứng. Cũng chưa thử hết nên mấy phần bên trong ra sao thì mình chưa rõ. Còn menu…

Like

b33 có giao diện tiếng Việt nên nhìn vào thấy gần gũi, không bị vướng mấy tên mục phải ngồi đoán nghĩa. Mình thích những trang để chữ dễ hiểu như vậy, nhất là lúc chỉ muốn ghé xem một chút chứ chưa định đọc kỹ hết. Có khi mở một trang lên mà nhãn nào cũng lạ là mình chẳng biết nên xem từ đâu nữa. Ở đây thì cách gọi tên khá quen, đọc lướt vẫn nắm được nội dung chính của từng phần. Một điểm nữa là các chuyên mục được chia riêng, nhìn đỡ lẫn vào nhau. Với mình, chỉ cần phân biệt được chỗ nào có nội dung gì là đã tiện hơn nhiều rồi,…

Like

https://roll88.run/ có cái mình khá thích là đọc phần giới thiệu không bị rối, vì nội dung được ngắt ra theo từng tiêu đề. Với người hay lướt nhanh như mình thì vậy dễ xem hơn, cần biết phần nào cứ nhìn tên mục rồi đọc tiếp, đỡ phải kéo qua một đoạn chữ dài. Mình chưa tìm hiểu sâu nên cũng không có nhận xét gì về dịch vụ thực tế đâu, chủ yếu đang nói cách trang đưa thông tin thôi. Chẳng hạn chuyện bảo mật có phần riêng, nên khi muốn xem trang nói gì về quyền riêng tư thì tìm cũng tiện. Không cần câu chữ cầu kỳ lắm, cứ trình bày rõ chỗ nào nói…

Like

https://nk88top.com/ nhìn phần giới thiệu thì mình để ý cách chia nội dung trước, chứ chưa tìm hiểu từng trò hay mấy thông tin khác. Mình thường thích trang nào có tiêu đề nói rõ bên dưới là gì, vì đọc trên điện thoại mà gặp một đoạn dài liền tù tì thì hơi ngại. Ở đây, phần thể thao và casino được giới thiệu riêng nên cũng dễ hình dung nội dung của từng mục, không phải tự đoán. Mình chỉ xem sơ qua nên chưa có nhận xét gì về trải nghiệm chơi thực tế đâu. Riêng cách đặt các tiêu đề cho từng nhóm nội dung thì khá dễ theo dõi, nhất là đoạn giới thiệu thể…

Like

REALCODE4YOU

Realcode4you is the one of the best website where you can get all computer science and mathematics related help, we are offering python project help, java project help, Machine learning project help, and other programming language help i.e., C, C++, Data Structure, PHP, ReactJs, NodeJs, React Native and also providing all databases related help.

​

Hire Us to get Instant help from realcode4you expert with an affordable price.

USEFUL LINKS

Discount

ADDRESS

Noida, Sector 63, India 201301

Follows Us!

  • Facebook
  • Twitter
  • Instagram
  • LinkedIn

OUR CLIENTS BELONGS TO

  • india
  • australia
  • canada
  • hong-kong
  • ireland
  • jordan
  • malaysia
  • new-zealand
  • oman
  • qatar
  • saudi-arabia
  • singapore
  • south-africa
  • uae
  • uk
  • usa

© 2026 IT Services provided by Realcode4you.com

bottom of page