Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with HTML-PHP and CSS files. Thank you! You\'ve been hired again by

ID: 3576681 • Letter: P

Question

Please help with HTML-PHP and CSS files. Thank you!

You've been hired again by Cities Unlimited to enhance their existing web site. The site uses the city table within the world database. The table has the following fields:
   ID
   Name
   CountryCode
   District
   Population
The site only uses the bold-faced fields. You will need to run the provided SQL script World-DatabaseBuild.sql to create the database on your MySQL server. The site has two pages:

City Manager
File name: CityManager.php
Purpose: this page enables the user to perform the following functions on the table:
   Select – retrieve records from the city table. The user may enter WHERE clause expressions in any of the three text boxes: ID, City, and Country.
   Add – add a record to the city table. The user must enter a City and Country. The ID field is auto-populated as the record is added to the table.
   Update – change a record in the city table. The user must enter an ID and City. Changes to Country are prohibited.
   Delete – delete a record from the city table. The user must enter an ID. Confirm that the user wants to delete the record.
Only one command is handled at a time. The command that the user wants to run will have text box entries while all the others will be blank. The page tests the text box fields in order, beginning with Select and ending with Delete. As soon as non-blank text boxes are found for a command, that is the command that will be processed. If the command is Add, Update, or Delete, perform a Select that returns all records as the last step for that command. This way, the data change will be seen in the query.

City Manager enhancements
For Select, add a sort order label and text box to enable the user to enter an ORDER BY clause.

City Manager Data
File name: CityManagerData.php
Purpose: this page shows the query criteria, query record count, and records returned from the query in an HTML table.

City Manager Data enhancements
Add logic to Add, Update, and Delete records from the City table. The Select command is already coded, except for the ORDER BY clause.
Style the table so that the:
   The background color of the header row is one color.
   The background colors of the detail rows alternates between two other colors.
Style the table so that the row background colors alternate between two colors.

.php files, .css and .sql files.

CityManager.php

<!DOCTYPE html>
<html>

<!--==================================================================
//
// Title: City Manager Page
// Course: CSC 5750
// Homework: 5
// Author: Dan Ouellette
// Date: 8 December 2016
// Description:
// This web site @@@
//
//=================================================================-->

<head>
  
   <title>City Manager</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="Dan Ouellette"/>
<meta name="description" content="City Manager"/>
<meta http-equiv="Expires" content="-1">
<link rel="stylesheet" type="text/css" href="CityManagerStyles.css">
  
</head>

<body>

<!-- Header -->
<h1>City Manager</h1>
<hr>

<form
method="get"
enctype="application/x-www-form-urlencoded"
action="http://127.0.0.1/CityManagerData.php"
>

<!-- Column headers -->
<label></label>
<label>ID</label>
<label>City</label>
<label>Country</label>
<br>

<!-- Select controls -->
<label>Select</label>
<input type="text" name="txtSelectID" />
<input type="text" name="txtSelectCity" />
<input type="text" name="txtSelectCountry" />
<br>

<!-- Add controls -->
<label>Add</label>
<label></label>
<input type="text" name="txtAddCity" />
<input type="text" name="txtAddCountry" />
<br>

<!-- Update controls -->
<label>Update</label>
<input type="text" name="txtUpdateID" />
<input type="text" name="txtUpdateCity" />
<label></label>
<br>

<!-- Delete controls -->
<label>Delete</label>
<input type="text" name="txtDeleteID" />
<label></label>
<label></label>

<br><br>
<input type="submit" value="Submit" />
<input type="reset" value="Reset">

</form>
  
<hr>
  
</body>

</html>

CityManagerData.php =

<!DOCTYPE html>
<html>

<!--==================================================================
//
// Title: City Manager Data Page
// Description:
// This web site @@@
//
//=================================================================-->

<head>
  
   <title>City Manager</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="Dan Ouellette"/>
<meta name="description" content="City Manager"/>
<meta http-equiv="Expires" content="-1">
<link rel="stylesheet" type="text/css" href="CityManagerStyles.css">
  
</head>

<body>

<!-- Get data -->
<?php
  
// Set connection parameters
$host = "127.0.0.1";
$user = "root";
$password = "mysql";
$database = "world";

// Connect to MySQL
$cxn = mysqli_connect($host, $user, $password, $database);
  
// Test if SELECT options entered
if(strlen($_GET["txtSelectID"]) != 0 ||
strlen($_GET["txtSelectCity"]) != 0 ||
strlen($_GET["txtSelectCountry"]) != 0)
{
  
// Build WHERE clause
if(strlen($_GET["txtSelectID"]) != 0)
$whereClause = "where ID='" . $_GET["txtSelectID"] . "'";
if(strlen($_GET["txtSelectCity"]) != 0)
{
if (strlen($whereClause) > 0)
$whereClause = $whereClause . " and Name='" . $_GET["txtSelectCity"] . "'";
else
$whereClause = "where Name='" . $_GET["txtSelectCity"] . "'";
}
if(strlen($_GET["txtSelectCountry"]) != 0)
{
if (strlen($whereClause) > 0)
$whereClause = $whereClause . " and CountryCode='" . $_GET["txtSelectCountry"] . "'";
else
$whereClause = "where CountryCode='" . $_GET["txtSelectCountry"] . "'";
}
  
// Create and submit SQL statement
$sql = "select ID, Name, CountryCode from city " . $whereClause;
$result = mysqli_query($cxn, $sql);

}
else
{
$whereClause = "ALL";
$sql = "select ID, Name, CountryCode from city;";
$result = mysqli_query($cxn, $sql);
}
  
// Test if connect failed
if($result == false)
{
echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
}

?>

<!-- Header -->
<h1>City Manager Data</h1>
<hr>

<!-- Criteria -->
<label>Select criteria:</label>
<?php
echo '<input type="text" class="criteria" value="', $whereClause, '" readonly>';
?>
<br><br>
  
<!-- Count -->
<label>City count:</label>
<?php
$rowCount = mysqli_num_rows($result);
echo '<input type="text" class="count" value="', $rowCount, '" readonly>';
?>
<br><br>
  
<!-- City table -->
<table>
  
<!-- Caption -->
<caption><b>Cities</b></caption>
  
<!-- Column specs -->
<colgroup>
<col width="25%">
<col width="50%">
<col width="25%">
</colgroup>
  
<!-- Column headers -->
<thead>
<tr>
<td>
<b>ID</b>
</td>
<td>
<b>City</b>
</td>
<td>
<b>Country</b>
</td>
</tr>
</thead>
  
<!-- Rows and columns -->
<tbody>
  
<!-- Build rows -->
<?php
  
// Loop to build rows
while($row = mysqli_fetch_row($result))
{

// Start row
echo "<tr>";
  
// Build columns
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
  
// End row
echo "</tr>";

}

?>
  
<tbody>

</table>

<hr>
  
</body>

</html>

CityManagerStyles.css =

/*==========================================================

Title: City Manager Web Site
Page: CityManagerStyles

==========================================================*/

/*==========================================================
Body
==========================================================*/
body
{
background-color:lavender;
font-family:verdana;
font-weight:bold
}

/*==========================================================
Button
==========================================================*/
button
{
font-size:28px;
text-align:center;
}

/*==========================================================
Headings
==========================================================*/
h1, h2, h3
{
color:black;
text-align:center;
}

/*==========================================================
Inputs
==========================================================*/

input
{
background-color:lightgreen;
font-size:18px;
width:140px;
}

input.criteria
{
width:600px;
}

input.count
{
text-align:right;
width:80px;
}

/*==========================================================
Label
==========================================================*/
label
{
display:inline-block;
width:140px;
font-size:18px;
}

/*==========================================================
Paragraph
==========================================================*/
p
{
font-size:18px;
}

Explanation / Answer

I did a totally static test page and it worked fine, then I tried this same technique within a WordPress site and no dice. The solution for me was to leave the file named style.css, and use .htaccess to parse it as PHP. Just make sure this code is in the .htaccess file (Apache servers only) at the same directory level as the CSS file. Then just use PHP inside it as you would any other PHP file.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote