示例#1
0
<?php

$genres = new GenresController();
if ($_POST['r'] == 'genre-delete' && !isset($_POST['crud'])) {
    $get_genre = $genres->get_genre($_POST['genre_id']);
    if (is_array($get_genre)) {
        $a_genre = [];
        foreach ($get_genre as $row) {
            $a_genre['genre_id'] = $row['genre_id'];
            $a_genre['genre'] = $row['genre'];
        }
        $template_genre = '
			<h2>Eliminar Género</h2>
			<form method="POST">
				<div class="p1  f2">
					¿Estas seguro de eliminar el Género: 
					<mark class="p1">%s</mark>?
				</div>
				<div class="p_25">
					<input  class="button  delete" type="submit" value="SI">
					<input class="button  add" type="button" value="NO" onclick="history.back()">
					<input type="hidden" name="genre_id" value="%s">
					<input type="hidden" name="r" value="genre-delete">
					<input type="hidden" name="crud" value="delete">
				</div>
			</form>
		';
        printf($template_genre, $a_genre['genre'], $a_genre['genre_id']);
    } else {
        $template = '
			<div class="container">
示例#2
0
    printf('
		<h2>Agregar Género</h2>
		<form method="POST">
			<div class="p_25">
				<input type="text" name="genre" placeholder="género" required>
				<input type="hidden" name="genre_id" value="0">
			</div>
			<div class="p_25">
				<input  class="button  add" type="submit" value="Agregar">
				<input type="hidden" name="r" value="genre-add">
				<input type="hidden" name="crud" value="save">
			</div>
		</form>
	');
} else {
    if ($_POST['r'] == 'genre-add' && $_POST['crud'] == 'save') {
        $genres = new GenresController();
        $save_genre = $genres->save_genre($_POST['genre_id'], $_POST['genre']);
        $template = '
		<div class="container">
			<p class="item  add">%s</p>
		</div>
		<script>
			window.onload = function (){
				reloadPage("generos")
			}
		</script>
	';
        printf($template, $save_genre);
    }
}
示例#3
0
<?php

printf('<h2>GESTIÓN DE GÉNEROS</h2>');
$genres = new GenresController();
$all_genres = $genres->get_genres();
if (is_array($all_genres)) {
    $template_all_genres = '
	<div class="item">
		<table>
			<tr>
				<th>Id</th>
				<th>Género</th>
				<th colspan="2">
					<form method="POST">
						<input type="hidden" name="r" value="genre-add">
						<input class="button  add" type="submit" value="Agregar">
					</form>
				</th>
			</tr>
	';
    foreach ($all_genres as $row) {
        $template_all_genres .= '
			<tr>
				<td>' . $row['genre_id'] . '</td>
				<td>' . $row['genre'] . '</td>
				<td>
					<form method="POST">
						<input type="hidden" name="r" value="genre-edit">
						<input type="hidden" name="genre_id" value="' . $row['genre_id'] . '">
						<input class="button  edit" type="submit" value="Editar">
					</form>