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.


63 Comments


ae888 thấy mọi người nhắc hoài vụ đá gà với mấy link C1 C2 C3 nên mình ghé qua xem thử giao diện ra sao, mình vốn không kỳ vọng nhiều nhưng ít nhất muốn biết có dễ đọc không; lướt một vòng thì trang trình bày theo kiểu chia khối khá rõ, kéo xuống là gặp tiêu đề lớn hiện ngay nên không phải đoán nội dung nằm đâu; mình để ý phần giới thiệu thương hiệu có nhắc mốc 2012, viết gọn kiểu tóm ý nên đọc nhanh vẫn hiểu, không bị dài dòng; trên điện thoại thao tác cũng ổn, menu nằm chỗ dễ thấy, chuyển mục không bị giật hay chờ quá lâu, các box nội…

Like

https://rr88.com.se/ lúc đầu mình cũng hơi nghi ngại vì mấy trang kiểu này hay rối, nhưng mở ra lướt thử thì thấy bố cục nhìn khá dễ nắm, kiểu liếc qua là biết chỗ nào là điều hướng chính và chỗ nào là nội dung, mình chỉ xem như người dùng bình thường chứ không soi kỹ gì cả mà vẫn không phải dừng lại đoán. Menu để ngay vị trí dễ thấy. Chuyển qua lại giữa các mục ổn. Mấy khối thông tin chia theo cột nên mắt quét nhanh vẫn theo kịp. Tiêu đề và khung nội dung tách bạch. Kéo xuống cũng không bị lạc. Nói chung dùng vài phút là quen tay, và mình thích cách…

Like

RR88COM so với mấy trang mình từng lướt trước đây thì cảm giác dễ làm quen hơn, kiểu mở ra là biết nên bấm chỗ nào chứ không phải đứng nhìn một hồi. Tối qua mình chỉ tranh thủ nghía nhanh lúc rảnh, chủ yếu xem cách họ bố trí thôi, và mình thấy cái menu để ngay vị trí dễ thấy nên chuyển qua lại mượt, không phải kéo lên kéo xuống tìm nút. Nội dung trên trang cũng trình bày theo từng khối rõ ràng, có đoạn dạng bảng cột nhìn gọn nên đọc lướt vẫn nắm được ý chính. Mình xem trên điện thoại vẫn ổn vì chữ với khoảng cách giữa các mục vừa đủ. Nói…

Like

Đọc mọi người bàn chuyện trải nghiệm trên điện thoại nghe cũng đúng kiểu mình hay gặp. vipwin tối qua mình tranh thủ vài phút lúc ngồi chờ nên mở ra xem thử cho biết, chủ yếu ngó cách họ trình bày thôi chứ không có thời gian mò sâu. Điều mình thấy dễ chịu là trang sắp xếp theo từng khối rõ ràng, nhìn phát biết chỗ nào là thông tin chính, kéo xuống cũng không bị rối mắt hay lạc mạch; chữ với khoảng trắng vừa đủ nên đọc lướt vẫn ổn. Mấy phần dạng bảng cột cũng làm khá gọn, hàng với cột thẳng thớm nên liếc nhanh là nắm được ý, không cần căng mắt. Nói…

Like

SC88 dạo này thấy mấy đứa bạn nhắc nên mình ghé thử cho biết thôi. Mình cũng không rảnh ngồi soi kèo hay gì, chủ yếu xem giao diện với cách họ trình bày nội dung ra sao. Ấn tượng đầu là load khá nhanh, bấm qua lại mấy mục không bị khựng nên lướt cũng nhẹ đầu. Trang nhìn thoáng, chữ không bị dồn dập, kiểu chia thành từng khối rõ ràng nên mới vào cũng không bị rối. Mình để ý phần “tổng quan” họ đặt khá dễ thấy, đọc vài dòng là hiểu họ đang giới thiệu hướng dịch vụ kiểu gì. Nói chung cảm giác thân thiện, giống kiểu làm cho người mới vào không phải…

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