Question

This is a website picture Northwind Customer Database Search List Records All Records CustomerName v CustomerName ContactName Address City PostalCode SThe html and css code is as follow

1 <! DOCTYPE html PUBLIC-//W3C//DTD XHTML 1.0 Transitional//EN http:L 3-<head> 4 Kmeta http-equiv-Content-Type content-width: 330px; height: 402px; z-index: 2; background-color: #CCCCCC ; padding-right: 10px; padding-left: 10px; 28 29 32 35 #seposition: absolute; left: 382px; top: 88px; width: 203px; height: 546px; z-index: 2; background-color: #CCCCCC; padding-right81<pxinput type-text name-customerName id-customerName /> 82 83 8 4 85 86 87<p>xinput type-text name-city id-city/form> 109 110 </div> 111<div id-listBox 112 113 114 115 116 <h2>List Records</h2> fieldset> <legend:All Records</legend> f/fieldset> 137 138 139 140 141 142 143 144 145 146 </div 147 /div> 148 /body> 149 K/html> 150 fieldset> legend>Find by ID</leAnd my problem is as follow use the php and mysql

Requirements: Use the customers table on your database Create the html document northwind.html - See attached formDesign.jpg

Northwind Customer Database Search List Records All Records CustomerName v CustomerName ContactName Address City PostalCode Search O ASC DESC List All Records Insert Record Country List City CustomerName ContactName Address City PostalCode Country List City Find by IID Find Insert
1 5 :#container { position: absolute left: 100px; top: 22px; width: 609px; height: 646px; z-index: 1; background-color: #336666; 10 12 13 16 #apDiv2 { position: absolute; left: 333px; top: 400px; width: 239px; height: 145px; Z-index: L; 18 19 20 21 23) 24 #insertBox { 25 26 27 28 position: absolute; left: 15px; top: 233px: width: 330px;
width: 330px; height: 402px; z-index: 2; background-color: #CCCCCC ; padding-right: 10px; padding-left: 10px; 28 29 32 35 #searchBox { 36 37 position: absolute; left: 15px; top: 88px; width: 330px; height: 135px; z-index: 2; background-color: #CCCCCC ; padding-right: 10px; padding-left: 10px; 39 40 42 43 46 #apDiv5 { position: absolute; left: 325px; top: 243px; width: 209px; height: 140px; z-index: 2; 48 49 50 52 53 position: absolute;
position: absolute; left: 382px; top: 88px; width: 203px; height: 546px; z-index: 2; background-color: #CCCCCC; padding-right: 5px; padding-left 5px; 56 57 58 59 60 62 63 64 65 itapDiv1 h1 { text-align: center; 67 68 I#container h1 { 69 70 71 72 K/style> 73 K/head> text-align: center; color: #FFF; 75 CustomerName p>〈 і nnut type-"text" 82 name-'' contactName" İd="contactName " /> 93
81 82 83 8 4 85 86 87xinput type-"text" name-"city" id-"city" /> CustomerName xinput type-"text" name-"contactName" id-"contactName" /> Contact Name pxinput type-"text" name-"address" id-"address" /> Address City /> 89 B 90 92 Kinput type-"submit" name-"submit" value "Insert" /> 93 /form> 95 96 97 100 E 101 102 103 104 105 106 107 108 109 Koption value-"CustomerName" CustomerName Koption value "ContactName" ContactName PostalCode Koption value-"Country" Country /select> pxinput type-"submit" name-"submit" value-"Search" /X/p>
/form> 109 110 111 xp> Kinput type-"radio" name-"radioAll" id-"radio" value-"asc" /i> ASC Kinput type-"radio" name-"radioAll" id-"desc" value-"desc" /> DESC 118 119 120 121 122 123 124 125 126 127 128 129 130 F 131 132 133 134 135 136 K/p> xp> Kinput type-"submit" name-"submit" value-"List All Records"/> /fieldset> fieldset>xlegend>List CityK/legend> xp> input type="text" name="City" id="city" /> xp> Kinput type-"submit" name-"submit" value-"List City"/> K/p> /form
/fieldset> 137 138 139 140 141 142 143 144 145 146 148 /body> 149 K/html> 150 fieldset> legend>Find by ID maxlength="4" method="post" id="findById" size="9" value-"Find" T> /form /fieldset>
Requirements: Use the customers table on your database Create the html document northwind.html - See attached formDesign.jpg Create the php file northwind.php to process the form data ngs to investıgate » hidden textfield SQL operators All forms on the page will post to the northwind.php file Use the hidden text field to identify which form button was clicked or use the button submits name & value, it's your choice Within the northwind php file use a switch command to decide which query should be ised List Records All records should list all records in the Customers table in the order depending on your radio button selection (default Asc) List City should only list the city typed in the input otherwise output "No records . found" Find by ID should only list one record and show all fields Insert Record insert new customers in the Customers table Display the inserted customer details and a message "New Record Inserted". . Search Find all records with the matching text and list them in Ascending CustomerName order
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is your php file. Mysql query is done using mysqli, because mysql is deprecated, if you want mysql query let me know. If you face any problem comment.

I don't know your desinging pattern so I outputted in clear text with table.

Code

<?php

$submit = $_POST["submit"];

switch ($submit) {
   case 'Insert':
       insertRecord();
       break;
  
   case 'Search':
       search();
       break;

   case 'List All Records':
       listAllRecords();
       break;

   case 'Find':
       findById();
       break;

   case 'List City':
       listCity();
       break;


   default:
       echo "Unknown request";
       break;
}

function insertRecord(){
   $customerName = $_POST["customerName"];
   $contactName = $_POST[contactName"];
   $address = $_POST["address"];
   $city = $_POST["city"];
   $postalCode = $_POST["postalCode"];
   $country = $_POST["country"];

  

   $sql = "INSERT into Customers(CustomerName, ContactName, Address, City, PostalCode, Country) VALUES('$customerName', '$contactName', '$address', '$city', '$postalCode', '$country');";

   $con = getSql();

   $con->query($sql);

   $insertId = $con->insert_id;

   echo "New Record inserted.";

   echo "<br>CustomerName: $customerName";
   echo "<br>ContactName: $contactName";
   echo "<br>Address: $address";
   echo "<br>City: $city";
   echo "<br>PostalCode: $postalCode";
   echo "<br>Country: $country";

   $con->close();
}


function search(){
   $fieldName = $_POST["fieldName"];
   $search = $_POST["search"];

   $sql = "SELECT * FROM Customers WHERE $fieldName='$search' ORDER BY CustomerName";

   $con = getSql();
   $result = $con->query($sql);

   echo "<table>";
   echo "<thead>";
   echo "<tr>";
   echo "<th>CustomerName</th>";
   echo "<th>ContactName</th>";
   echo "<th>Address</th>";
   echo "<th>City</th>";
   echo "<th>PostalCode</th>";
   echo "<th>Country</th>";
   echo "</tr>";
   echo "</thead>";
   echo "<tbody>";
   while ($row = $result->fetch_assoc()) {
       echo "<tr>";
       echo "<td>$row[CustomerName]</td>";
       echo "<td>$row[ContactName]</td>";
       echo "<td>$row[Address]</td>";
       echo "<td>$row[City]</td>";
       echo "<td>$row[PostalCode]</td>";
       echo "<td>$row[Country]</td>";
       echo "</tr>";
   }
   echo "</tbody>";
   echo "</table>";

   $con->close();
}


function listAllRecords(){
   $orderBy = $_POST["radioAll"];
   if (empty($orderBy)) {
       $orderBy = "asc";
   }
  
   $sql = "SELECT * FROM Customers ORDER BY $orderBy";
   $con = getSql();
   $result = $con->query($sql);

   echo "<table>";
   echo "<thead>";
   echo "<tr>";
   echo "<th>CustomerName</th>";
   echo "<th>ContactName</th>";
   echo "<th>Address</th>";
   echo "<th>City</th>";
   echo "<th>PostalCode</th>";
   echo "<th>Country</th>";
   echo "</tr>";
   echo "</thead>";
   echo "<tbody>";
   while ($row = $result->fetch_assoc()) {
       echo "<tr>";
       echo "<td>$row[CustomerName]</td>";
       echo "<td>$row[ContactName]</td>";
       echo "<td>$row[Address]</td>";
       echo "<td>$row[City]</td>";
       echo "<td>$row[PostalCode]</td>";
       echo "<td>$row[Country]</td>";
       echo "</tr>";
   }
   echo "</tbody>";
   echo "</table>";

   $con->close();
}

function findById(){
   $id = $_POST["findById"];

   $sql = "SELECT * FROM Customers WHERE id=$id LIMIT 1";

   $con = getSql();

   $result = $con->query($sql);

   $row = $result->fetch_assoc();

   echo "<table>";
   echo "<thead>";
   echo "<tr>";
   echo "<th>CustomerName</th>";
   echo "<th>ContactName</th>";
   echo "<th>Address</th>";
   echo "<th>City</th>";
   echo "<th>PostalCode</th>";
   echo "<th>Country</th>";
   echo "</tr>";
   echo "</thead>";
   echo "<tbody>";
  
   echo "<tr>";
   echo "<td>$row[CustomerName]</td>";
   echo "<td>$row[ContactName]</td>";
   echo "<td>$row[Address]</td>";
   echo "<td>$row[City]</td>";
   echo "<td>$row[PostalCode]</td>";
   echo "<td>$row[Country]</td>";
   echo "</tr>";
  
   echo "</tbody>";
   echo "</table>";

   $con->close();

}

function listCity(){
   $city = $_POST["city"];

   $sql = "SELECT * FROM Customers WHERE city LIKE '$city'";

   $con = getSql();

   $result = $con->query($sql);

   if ($result==false || $result->num_rows < 1) {
       echo "No Records found.";
   }else{
       echo "<table>";
       echo "<thead>";
       echo "<tr>";
       echo "<th>CustomerName</th>";
       echo "<th>ContactName</th>";
       echo "<th>Address</th>";
       echo "<th>City</th>";
       echo "<th>PostalCode</th>";
       echo "<th>Country</th>";
       echo "</tr>";
       echo "</thead>";
       echo "<tbody>";
       while ($row = $result->fetch_assoc()) {
           echo "<tr>";
           echo "<td>$row[CustomerName]</td>";
           echo "<td>$row[ContactName]</td>";
           echo "<td>$row[Address]</td>";
           echo "<td>$row[City]</td>";
           echo "<td>$row[PostalCode]</td>";
           echo "<td>$row[Country]</td>";
           echo "</tr>";
       }
       echo "</tbody>";
       echo "</table>";
   }

   $con->close();
}

function getSql(){
   $con = mysqli_connect("localhost","username","password","dbname");

   return $con;
}


Add a comment
Know the answer?
Add Answer to:
This is a website picture The html and css code is as follow And my problem is as follow use the php and mysql Northwind Customer Database Search List Records All Records CustomerName v CustomerName...
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
  • in the following java script code follow the instructions provided <!DOCTYPE html> <html> <head> <!-- JavaScript...

    in the following java script code follow the instructions provided <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 5 Hands-on Project 5-2 Author: Date:    Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hands-on Project 5-2</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 5-2 </h1> </header> <article> <h2>Change of address form</h2> <form> <fieldset id="contactinfo"> <label for="addrinput"> Street Address </label> <input type="text" id="addrinput" name="Address" /> <label for="cityinput"> City </label> <input type="text" id="cityinput" name="City"...

  • As part of this assignment we are using the base Gallery HTML and writing JavaScript code...

    As part of this assignment we are using the base Gallery HTML and writing JavaScript code that will: 1) preload the images provided to us, 2) Create rollover functionality for each of the thumbnails in your image gallery 3) Use appropriate images found in the images folder. 4) Write developer comments to describe the variables being declared and explain the functions and logical blocks of JavaScript code pertaining to the gallery. I know it has to be an external JS...

  • Does my css style sheet look okay? /* Author:       Your Name --> Natasha Strange /*...

    Does my css style sheet look okay? /* Author:       Your Name --> Natasha Strange /* Date:           Today's Date --> September 22, 2019 /* Description:   Lab Number --> Lab04 /*doctype css*/ @import url(fonts/chuckfive.css); @import url(fonts/merriweather.css); body    { background-color: rgb(199,201,191);        } div { border: 1px solid black;        padding: 100px 100px 100px 100px;        background-color: gray; } nav { text-align: center;    color: rgb( 7,20,138); } header, footer   { background-color: rgb(199,201,199);        color:...

  • Hello, I am designing a website for my class. I am using HTML/CSS/Jscript. I need to...

    Hello, I am designing a website for my class. I am using HTML/CSS/Jscript. I need to have my text in the body, white. All text and the picture centered but how do I have margins on the left and right side?. I have a figcaption and I dont know have to place it under the picture but I am having a hard time. Can you help me? Thank you! HTML <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet"...

  • the is my HTML and CSS code. I didn't attach the image or the CSS file...

    the is my HTML and CSS code. I didn't attach the image or the CSS file because of the space limit. two things I wanted to incorporate on this page are to make "MY TOP 3 MUSIC GENRES" blink using javascript and to make the video links autoplay using javascript both should be using javascript requirement: our professor told us not to use <div> or alert. thank you for your help <!DOCTYPE html> <!-- I used w3school for the formatting...

  • Hello, this is my code. moest of the things works but when select the price, i...

    Hello, this is my code. moest of the things works but when select the price, i just dont get my total. can someone help me out . thank you My queshion is also here The page will simulate the site for a Chicago-based small bus line that travels to St Louis, Milwaukee, and Detroit. Here are the requirements: The home page (i.e. the main page) should simply be the heading, image, and slogan of the site.  The home page should NOT...

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
ADVERTISEMENT