Skip to content

Instantly share code, notes, and snippets.

@sroehrl
Created April 21, 2020 14:59
Show Gist options
  • Save sroehrl/e3b5adbd8ff58c97c2b938b09a966a2e to your computer and use it in GitHub Desktop.
Save sroehrl/e3b5adbd8ff58c97c2b938b09a966a2e to your computer and use it in GitHub Desktop.
smucka
<?php
define('varovalka', true);
ini_set('error_reporting',E_ALL);
ini_set('display_errors',1);
include_once 'shared.php';
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Seznam filmskih igralcev</title>
</head>
<body>
<a href="<?= getvar('APP_URL'); ?>/app">Seznam</a>
<hr>
<?php
if (isset($_GET['vec']) && $_GET['vec'] >= 0) :
$raw = file_get_contents(getvar('APP_URL') . '/api/index.php?igralec=' . intval($_GET['vec']));
$en = json_decode($raw, true);
?>
<!-- Več o posameznem igralcu ali igralki -->
Samo en igralec/igralka
<table>
<tr>
<td>Ime:</td>
<td><?php echo $en['ime']; ?></td>
</tr>
<tr>
<td>Priimek:</td>
<td><?php echo $en['priimek']; ?></td>
</tr>
<tr>
<td>Žanri:</td>
<td><?php echo implode(', ', $en['zanri']); ?></td>
</tr>
<tr>
<td>Filmi</td>
<td>
<?php // alternativa vrstici 32
foreach ($en['filmi'] as $index => $film) {
echo ($index === 0 ? '' : ', ') . $film;
}
?>
</td>
</tr>
</table>
<?php else :
// pokličemo surove podatke
$raw = file_get_contents(getvar('APP_URL') . '/api/index.php');
// surove podatke pretvorime v asociativni array
$array = json_decode($raw, true);
?>
<!-- Cel seznam vseh igralcev -->
Cel seznam
<table>
<?php foreach ($array as $index => $igralec) : ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo $igralec['ime'] ?></td>
<td><?php echo $igralec['priimek'] ?></td>
<td><a href="<?= getvar('APP_URL'); ?>/app/index.php?vec=<?= $index; ?>">Preberi več</a></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment