Question

Create web pages for your database using PHP. You should have one page that will return...

Create web pages for your database using PHP. You should have one page that will return all the information from the database. You should create additional pages that will allow you to do various queries of your database. You should be able to retrieve and insert data; also include functionality to delete data from your database. Create an html form that will allow you to enter in new information for the database. The information should be handled by a PHP script that will take the data and input it into the database. Create a separate home page that contains links to each of the web pages you create to access your database.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CREATE TABLE `Student`.`studentdetails` ( `stud_id` INT NOT NULL AUTO_INCREMENT , `firstname` VARCHAR(100) NOT NULL , `lastname` VARCHAR(100) NOT NULL , `subject` VARCHAR(100) NOT NULL , PRIMARY KEY (`stud_id`)) ENGINE = InnoDB; //This is a sample database

PHP code for display,Add and Delete are mentioned below

------------------------------------------------------------------------------------------------------------------------------------

home.html

-------------------------------------------------------------------------------------------------------

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Home Page</title>
</head>
<body>
<form>
<div class="container" style="padding: 16px;">
<h1>Home Page</h1>
<hr>
<p>
  
</p>
<p >
<a href="displays.php">View All Details</a>
</p>
<p>
<a href="addnewdata.html">Add</a>
</p>

</div>   
</form>
</body>
</html>

---------------------------------------------------------------------------------------------------------------------------------------------------

display.php

----------------------------------------------------------------------------------------------------------------------------------------------------

<?php
$link = mysqli_connect("localhost", "root", "", "student");

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SELECT * FROM studentdetails";
if($result = mysqli_query($link, $sql))
{
if(mysqli_num_rows($result) > 0)
{
echo "<table>";
echo "<tr>";
echo "<th>Id</th>";
echo "<th>First Name</th>";
echo "<th>Last Name</th>";
echo "<th>Subject</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['stud_id'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td><a href=\"delete.php?id=" . $row['stud_id'] . "\">Delete</a></td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
}
else
{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);
?>

--------------------------------------------------------------------------------------------------------------------------------------------------------

addnewdata.html

----------------------------------------------------------------------------------------------------------------------------------------------------------

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Record Form</title>
</head>
<body>
<form action="addnewdata.php" method="post">
<p>
<label for="firstname">First Name:</label>
<input type="text" name="first_name" id="firstName">
</p>
<p>
<label for="lastname">Last Name:</label>
<input type="text" name="last_name" id="lastName">
</p>
<p>
<label for="Subject">Subject:</label>
<input type="text" name="subject" id="subject">
</p>
<hr>
<input type="submit" value="Submit">
</form>
</body>
</html>

-------------------------------------------------------------------------------------------------------------------------------------------------------

addnewdata.php

-------------------------------------------------------------------------------------------------------------------------------------------------------

<?php

$link = mysqli_connect("localhost", "root", "", "student");

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}

$first_name = mysqli_real_escape_string($link, $_REQUEST['first_name']);
$last_name = mysqli_real_escape_string($link, $_REQUEST['last_name']);
$subject = mysqli_real_escape_string($link, $_REQUEST['subject']);

// Attempt insert query execution
$sql = "INSERT INTO studentdetails (firstname, lastname, subject) VALUES ('$first_name', '$last_name', '$subject')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// Close connection
mysqli_close($link);
?>

-------------------------------------------------------------------------------------------------------------------------------------------------------------

delete.php

------------------------------------------------------------------------------------------------------------------------------------------------------------

<?php

$link = mysqli_connect("localhost", "root", "", "student");

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$stud_id= $_GET['id'];
$sql = "DELETE FROM studentdetails WHERE stud_id='$stud_id'";

if (mysqli_query($link, $sql)) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error($conn);
}

// Close connection
mysqli_close($link);
?>

Add a comment
Know the answer?
Add Answer to:
Create web pages for your database using PHP. You should have one page that will return...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create two web pages as follows: Page 1: An html page with a form that will...

    Create two web pages as follows: Page 1: An html page with a form that will allow the user to enter their name and gender <m/f> Page 2: A Php document that will process the data from the html form to display a welcome message of either ‘Welcome Mr. <submitted name>’ or ‘Welcome Ms. <submitted name>’ The <submitted name> is what the user submitted in the HTML form.

  • PHP you need to create a form to allow the user to enter their name, email,...

    PHP you need to create a form to allow the user to enter their name, email, and address information. That information will be sent to a PHP script that will process and display that information. Your assignment should have two pages. The first page is straight html (user_input.html) that has a form with the appropriate form elements to collect the user input. The form should then be submitted using the POST method to a php script (display_user_info.php) that will process...

  • Using PHP and MySQL, create a Web page to be used for storing software development bug reports in...

    Using PHP and MySQL, create a Web page to be used for storing software development bug reports in a MySQL database. Include fields such as product name and version, type of hardware, operating system, frequency of occurrence, and proposed solutions. Include links on the main page that allow you to create a new bug report and update an existing bug report. I have tried the various solutions provided previously for this exercise, but it does not work because every author...

  • In this assignment you will combine HTML, PHP, and SQL in order to create a web...

    In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies. Task 1 Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the...

  • Instructions Using Php and MySQL, database from Xampp In this assignment, you will create an application...

    Instructions Using Php and MySQL, database from Xampp In this assignment, you will create an application using PHP and MySQL, incorporating all of the skills that you have learned throughout the course. As you complete the project, be sure that you are using the correct format and syntax as well as the appropriate structure for your coding. To move forward to the next module, you will need to demonstrate mastery by scoring an 80% or higher. If you score less...

  • PHP Programming In this project, you will create a Web page that allows visitors to your...

    PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...

  • The following needs to be on a basic web page using the PHP request-response model to...

    The following needs to be on a basic web page using the PHP request-response model to create a log-in form that permits the user to request access to an administration console for a Web-based product catalog of your choosing. Server-side scripting will authenticate the user based on valid users found in a text file verified by the server. Once a user logs on to the administration console, he or she will need a form that will allow an authenticated user...

  • PHP coding (please use mysqli instead of mysql) Create an Admin Control Panel page for your...

    PHP coding (please use mysqli instead of mysql) Create an Admin Control Panel page for your shop. Your admin page can perform the following tasks: Add product to the database. (Only text information) Delete product from the database View products from the database Edit/update product to the database Challenge: Can upload the image of each product to the database Read and display the products from database in home page

  • HTML Web Page project: Need help to create a web page exactly as the example below...

    HTML Web Page project: Need help to create a web page exactly as the example below using HTML. I need the source code. Page 1 of CA272 Midterm Welcome to your name's CA272 Midterm Text In this class, I learned how to... 1. create an X)HTML web page, where I can 2. change the size of my font, 3. change the color of my fonts, 4. change my font style, 5. and change the background color of my web page....

  • Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file,...

    Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file, "insert-user-form.php", with a form that has the following fields: - First Name (text) - Last Name (text) - Email (text) - Password (text) - Submit button Create another PHP file, "insert-exercise-form.php" with a form that has the following fields: - Exercise Name (text) - Description (text) - Demonstration Image (file) - Submit button Create another PHP file, "login-user-form.php" with a form that has the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT