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

Need help combining two PHP files to product the following: PART3 i. Combine par

ID: 3724195 • Letter: N

Question

Need help combining two PHP files to product the following:

PART3

i. Combine parts 1 and 2 to produce the following:

ii. As you can see from the URL, the PHP file is named "printcollections.php".

iii. Artists file needs to be read into a table first, then go over the Arts list one by one and use "artistID" to search for "artistName".

iv. Please note that whenever an artist is changed the background color of that artist is also changed. Choose your own favorite color. Google "PHP predefined color" for a list of predefined colors.

Part 1

e01artists.txt

2              Ames

3              Aserty

4              Baron

7              Blain

8              Blum

9              Budd

12           Chico

14           Cox

16           Curtis

17           Dawson

19           Dill

22           Fratt

23           Garber

24           Garin

25           Giama

28           Guys

29           Hamend

32           Ibe

35           Irvin

38           Kritz

40           Long

43           Lutes

48           Metz

49           Miller

50           Mogan

52           Novarre

54           Ortega

55           Parker

56           Penn

59           Quiroz

60           Rath

Part 2

e01arts.txt

1042       Coffee on the Trail           2              7544

1013       Superstitions     3              78000

1021       Bead Wall            3              14000

1034       Beaver Pole Jumble         3              28000

1063       Asleep in the Garden      3              110000

1070       Beginnings          4              27500

1049       Buttercup with Red Lip   7              400

1018       Mountain Scene               8              2500

1055       Starlit Evening   9              9500

1003       Spring Flowers 12           2400

1039       Treachery            14           20000

1102       Crying Hats         14           10000

1052       American Rodeo               16           3500

1059       Dwelling               17           16000

1011       Eve         19           975

1109       Friends 22           16000

1084       Crossing the Platt River 23           2200

1072       Funnel 24           4500

1115       Starry Night        25           8500

1009       Amen    28           3000

1030       Ash Bench           28           13000

1043       Creosote Bushes              28           18000

1078       Chuckwagon      28           32000

1041       Night Version    29           3800

1082       Spring Flowers 29           20000

1006       House Remembered      32           700

1107       Striking It Rich    35           1750

1045       Leaf Patterns     38           2100

1100       Hungry Cowboys              38           750

1106       Horse Corral       40           12500

1044       Mexican Fiesta 43           14000

1024       Spirit and Nature              48           592

1067       Owl in Flight       49           7000

1001       Red Rock Mountain         50           18000

1028       Tired Cowboy    50           4700

1054       Snake Charmer 50           4500

1068       Moonlight           50           9750

1069       Renaissance       50           5500

1113       Shadow House 50           5500

1114       Storytelling at the Campfire         50           18000

1002       Offerings             52           10000

1091       Stone Palette     54           11500

1074       Storm on the Rise            55           8000

1098       Sweet Project    56           592

1080       The Dust Behind               59           18000

1058       The Gathering   60           250

=======================

These are the code

Part 1

printartists.php file

<?php require_once 'function.php'; /* calling our function.php file */ ?>
< !DOCTYPE html>
< html>
< head>
< link rel="stylesheet" href="Style.css" type="text/css" /> <!-- linking our css file -->
< /head>
< body>
< ?php
ReadText(); /* calling our php function ReadText() */
?>
< /body>
< /html>

function.php file

<?php
function ReadText() /* creating a function ReadText() */
{
$file = fopen("e01artists.txt", "r") or die("Error while opening file"); /* creating a variable $file to hold the php function fopen result */
$counter= 0; /* creating a variable called $counter which we use for number column of the table */
echo "<table>"; /* creating a html table using php echo */
echo "<tr><td colspan='3'>Lee Hsu's Artist List</td></tr>"; /* creating table rows using php echo */
echo "<tr><td>Number</td><td>Artist No</td><td>Artist Name</td></tr>";
/* Output one line until end-of-file */
while(!feof($file)) { /* creating a while loop to read all the data of the text file one by one until it reach end */
$output = fgets($file); /* storing text file data inside variable $output */
$artist = explode(' ', $output,2); /*converting text file data into array using php explode function and storing the array into variable $artist */
echo "<tr><td>".++$counter."</td><td>".$artist[0]."</td><td>".$artist[1]."</td></tr>"; /* here we pre increment variable $counter to increment the value of counter on every next row and showing values of text file where $artist[0] is the artist number and $artist[1] is the artist name */
}
fclose($file); /* closing file */
echo "<tr><td colspan='3'>Total Artist =".$counter."</td></tr>";
echo "</table>"; /* closing Table */
}
?>

style.css file

table {
border-collapse: collapse; /* collapse the table border into single border */
}

table, td, th {
border: 1px solid black; /* set the width and color of the border */
}

/* css of the table first row */
tr:nth-child(1) {
background-color: #ffdd02; /*setting yellow color */
text-align: center; /* aligning text to center */
font-weight: bold; /* making text bolder */
}

/* css of the table second row */
tr:nth-child(2) {
background-color:#b7d2ff; /*setting light blue color */
text-align: center; /* aligning text to center */
font-weight: bold; /* making text bolder */
}

/* css of the table last row */
tr:last-child {
text-align: center; /* aligning text to center */
background-color:#ffa201; /*setting orange color */
}

Part 2

arts.css table { border-collapse: collapse; /* collapse the table border into single border */ } table, td, th { border: 1px solid black; /* set the width and color of the border */ } /* css of the table first row */ tr:nth-child(1) { background-color: #ffdd02; /*setting yellow color */ text-align: center; /* aligning text to center */ font-weight: bold; /* making text bolder */ } /* css of the table second row */ tr:nth-child(2) { background-color:#b7d2ff; /*setting light blue color */ text-align: center; /* aligning text to center */ font-weight: bold; /* making text bolder */ } /* css of the table last row */ tr:last-child { text-align: center; /* aligning text to center */ background-color:#ffa201; /*setting orange color */ } printarts.php <?php require_once 'function2.php'; /* calling our function.php file */ ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="arts.css" type="text/css" /> <!-- linking our css file --> </head> <body> <?php ReadText(); /* calling our php function ReadText() */ ?> </body> </html> ============== function2.php <?php function ReadText() /* creating a function ReadText() */ { $file = fopen("e01arts.txt", "r") or die("Error while opening file"); /* creating a variable $file to hold the php function fopen result */ $counter= 0; /* creating a variable called $counter which we use for number column of the table */ echo "<table>"; /* creating a html table using php echo */ echo "<tr><td colspan='5'>Lee Hsu's Art List</td></tr>"; /* creating table rows using php echo */ echo "<tr><td>Number</td><td>Art No</td><td>Art Name</td><td>Artist No</td><td>Market Value</td></tr>"; /* Output one line until end-of-file */ while(!feof($f)) { /* creating a while loop to read all the data of the text file one by one until it reach end */ $output = fgets($f); /* storing text file data inside variable $output */ $art = explode(' ', $output,2); /*converting text file data into array using php explode function and storing the array into variable $artist */ echo "<tr><td>".++$count."</td><td>".$art[0]."</td><td>".$art[1]."</td></tr>"; /* here we pre increment variable $counter to increment the value of counter on every next row and showing values of text file where $artist[0] is the artist number and $artist[1] is the artist name */ } fclose($f); /* closing file */ echo "<tr><td colspan='2'>Total Art =".$count."</td><td colspan='3'>Total Value =</td></tr>"; echo "</table>"; /* closing Table */ } ?> -> O localhost/csc264/e01/printcollections.php CSC264: Exam1-Part3 Lee Hsu's Collection Number Artist ID Artist Name Art No Market Value 7544 78000 14000 28000 110000 27500 Art Name 1042 1013 Coffee on the Trail Superstitions Aserty Aserty 1021 Bead Wall Aserty Baron 1034 1063 1070 Beaver Pole Jumble Asleep in the Garden Beginnings (Many Lines in betweern) 45 59 Quiroz 1080 The Dust Behind 4660 Rath1058The Gathering 18000 250 Total Artists 31 Total Arts 46 Total Value = 605003

Explanation / Answer

function.php

<?php
function ReadText() /* creating a function ReadText() */
{
$i=0;
$j=-1;
$value=0;
$arr=fopen("e01arts.txt","r");
$arr1=fopen("e01artists.txt","r");
echo"<table border=1>";
echo"<caption >CSC264: Exam1-Part3<br>Lee Hsu's Collection</caption>";
echo"<tr><th>Number</th><th>Artist ID</th><th>Artist Name</th><th>Art No</th><th>Art Name</th><th>Artist No</th><th>Market Value</th></tr>";

while(!feof($arr))
{
$data1=fgets($arr1);
$ans1=explode(" ",$data1);
$data=fgets($arr);
$ans=explode(" ",$data);
$a=$i+1;
$value=$value+$ans[3];
echo "<tr><td>".$a."</td><td>".$ans1[0]."</td><td>".$ans1[1]."</td><td>".$ans[0]."</td><td>".$ans[1]."</td><td>".$ans[2]."</td><td>".$ans[3]."</td></tr>";
$i++;
if(!feof($arr1))
{
$j++;
}
}


echo(" ");
echo("<tr class='count'><td colspan=2>"."Total Artists=".$j."</td><td colspan=2>"."Total Arts=".$i."</td><td colspan=3>"."Total Value=".$value."</td></tr>");
echo"</table>";
fclose($arr);
fclose($arr1);
}
?>

printcollections.php

<?php require_once 'function.php'; /* calling our function.php file */ ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
ReadText(); /* calling our php function ReadText() */
?>
</body>
</html>

style.css

table

{
border-collapse: collapse;
}

table, td, th

{
border: 1px solid black;
}


tr:nth-child(1) {
background-color: #ffdd02;
text-align: center;
font-weight: bold;
}


tr:nth-child(2) {
background-color:#b7d2ff;
text-align: center;
font-weight: bold;
}


tr:last-child {
text-align: center;
background-color:#ffa201;
}

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