PHP Taskbook Level 9.7

Задание 1

Make a site that gives a random prediction, good or bad, when you visit it. Predictions should be stored in the DB. When you refresh the page, the prediction should not change during the current day.

Задание 2

Given an arbitrary two-dimensional array:

php[
  [11, 12, 13, 14, 15],
  [21, 22, 23, 24, 25],
  [31, 32, 33, 34, 35],
  [41, 42, 43, 44, 45],
  [51, 52, 53, 54, 55],
]

Zero out the elements that are not on the diagonals:

php[
  [11,  0,  0,  0, 15],
  [ 0, 22,  0, 24,  0],
  [ 0,  0, 33,  0,  0],
  [ 0, 42,  0, 44,  0],
  [51,  0,  0,  0, 55],
]
Задание 3

Let the file contain the following JSON:

data.json{
  [
    "catg": "catg1",
    "name": "prod1",
    "cost": "100"
  ],
  [
    "catg": "catg2",
    "name": "prod2",
    "cost": "200"
  ],
  [
    "catg": "catg3",
    "name": "prod3",
    "cost": "300"
  ]
}

Generate the following HTML code using the file data and send it to the browser:

html<table>
  <tbody>
    <tr>
      <td>1</td>
      <td>catg1</td>
      <td>prod1</td>
      <td>100</td>
    </tr>
    <tr>
      <td>2</td>
      <td>catg2</td>
      <td>prod2</td>
      <td>200</td>
    </tr>
    <tr>
      <td>3</td>
      <td>catg3</td>
      <td>prod3</td>
      <td>300</td>
    </tr>
  </tbody>
</table>