Question 1 Finish the following PHP code problem Given the p

Question 1

Finish the following PHP code problem. Given the provided array of countries, output the information in the array using one or more loops within a two-column HTML table. The first column will display the country name and the second column the capital city name. Make the country name a link to country.php; pass the country code (the first element in the array) as a query string with a name of code (e.g., country.php?code=AR). Then the country.php script will display an image of the country based on the received code. All the images should be stored in a directory called images and their names are stored in $images array.

$countries = array

( array(\"AR\",\"Argentina\",\"Buenos Aires\"),

array(\"AT\",\"Austria\",\"Vienna\"),

array(\"BE\",\"Belgium\",\"Brussels\"),

array(\"CA\",\"Canada\",\"Ottawa\") );

$images = array(“AR” => “ar.jpg”, “AT” => “at.jpg”, “BE” => “be.jpg”, “CA” => “ca.jpg”);

Question 2

Write the complete PHP page (players.php) that will generate the outcome shown below. The data comes from a text file named players.txt, whose content is shown below. Notice the html table you will need to generate. Don’t worry about any styling. Notice that you will have to calculate total points for each player (goals+assists).

players txt Notepad File Edit Format View Help M. St. Louis, 38,56,Tampa Bay I., Kovalchuk, 41, 46, Atlanta Sakic, 33, 54, Colorado M. Naslund, 35,49,Vancouver M. Hossa, 36,46,0ttawa

Solution

Question-1:-

<html>
<head>
<title> displaying image from a array based query</title>
</head>
<body>
<?php
$countries = array
(
array(\"AR\",\"Argentina\",\"Buenos Aires\"),
array(\"AT\",\"Austria\",\"Vienna\"),
array(\"BE\",\"Belgium\",\"Brussels\"),
array(\"CA\",\"Canada\",\"Ottawa\")
);
$images = array(“AR” => “ar.jpg”, “AT” => “at.jpg”, “BE” => “be.jpg”, “CA” => “ca.jpg”);
$Images = \'/home/user/Images\';
$file_display = array(\'jpg\', \'jpeg\', \'png\', \'gif\');
<a href=\"county.php\"><img src=\"<?php echo countries.images(\'$countries.array[0]\'); ?>\" style=\"vertical-align: middle;\"></a>

if ( file_exists( $images ) == false ) {
echo \'Directory \\\'\', $images, \'\\\' not found!\';
} else {
$dir_contents = scandir( $images);
   if(country.php?code=$countries.array[0])
echo <table>
echo \"<tr>\"
echo <th>country_name</th>
       echo <th>capital city name</th>
echo </tr>
echo <tr>
echo <td> $countries.array[1] </td>
   echo <td> $countries.array[2] </td>
echo </tr>
echo </table>
?>
</body>
</html>

Question-2:-

<html>
<head><title> text file to sum </title>
<body>
<?php
$myfilename = \"players.txt\";
if(file_exists($myfilename))
   {
echo file_get_contents($myfilename);
   echo <table>
   echo <h3>top scoreres in the nhl</h3>
  
   echo \'<table>
<tr>
<th>playerName</th>
<th>team</th>
       <th>Goals</th>
       <th>Assists</th>
       <th>totalpoints</th>
</tr>\';

while ($row = mysqli_fetch_array($myfilename))
{
echo \'
<tr>
<td>\'.$row[\'playerName\'].\'</td>
<td>\'.$row[\'team\'].\'</td>
           <td>\'.$row[\'Goals\'].\'</td>
           <td>\'.$row[\'Assists\'].\'</td>
           <td>\'.$row[\'totalpoints\']=row[\'Goals\']+row[\'Assists\'].\'</td>
</tr>\';
       echo \'
       </table>
}
   else
       echo \"$ myfilename not found\";
   ?>
</body>
</html>

Question 1 Finish the following PHP code problem. Given the provided array of countries, output the information in the array using one or more loops within a tw
Question 1 Finish the following PHP code problem. Given the provided array of countries, output the information in the array using one or more loops within a tw

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site