示例#1
0
 public function read($id)
 {
     $row = $this->spg_model > get_by_id($id);
     if ($row) {
         $data = array('id' => $row->id);
         $this->template->load('templates/admin/template', 'protected/reporthrd/reportsales_read', $data);
     } else {
         $this->session->set_flashdata('message_text', 'Record Not Found');
         redirect(site_url('protected/'));
     }
 }
示例#2
0
<?php namespace Blog\DB;

require 'blog.php';

//fetch data from posts
$post = get_by_id((int)$_GET['id'], $conn);

if ( $post ) {
	$post = $post[0];
	
	view('single', array(
	'post' => $post
	));


} else {
	header('location:./');
}


示例#3
0
<?php

namespace blog;

require "../connect.php";
# on scrip GET =show post details to edit
# make sure there is an id attached to the get requrest / url
if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($_GET['id'])) {
    #make sure it is a valid id for an existing post
    if ($post = get_by_id($handler, "posts", $_GET['id'])) {
        # collect post info and fill them in the view
        $id = $_GET['id'];
        $title = $post['title'];
        $body = $post['body'];
        $authors = get_authors_options($post['author']);
        view("updatePost.php", "updatePost.css", ["title" => $title, "body" => $body, "id" => $id, "authors" => $authors]);
    } else {
        header("location:index.php");
    }
}
# on script POST = save the edits to the db
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    if (empty($_POST['title']) || empty($_POST['body']) || !isset($_POST['author'])) {
        $status = "Fill both title and body first";
        $color = "red";
    } else {
        if (query($handler, "update posts set title=:t,body=:b,author=:a where id=:id", [":t" => $_POST['title'], ":b" => $_POST['body'], ":id" => $_POST['id'], ":a" => $_POST['author']])) {
            $status = "post is updated";
            $color = "green";
        } else {
            $status = "an error has occurred";
示例#4
0
<?php

namespace blog;

require "connect.php";
if (!empty($_GET['id'])) {
    $get = get_by_id($handler, "posts", $_GET['id']);
    $single = "<h3>" . $get['title'] . '</h3>';
    $single .= '<p>' . $get['body'] . '</p>';
    $single .= '<p><i>Author id is :' . $get['author'] . '</i></p>';
    view("single.view.php", "single.css", ["singlePost" => $single]);
} else {
    header("location:index.php");
}
示例#5
0
    redirect('transaksi_choose.php');
} else {
    $id_pembayaran = $_SESSION['id_pembayaran'];
}
$qpembayaran = get_by_id('pembayaran', 'id', $id_pembayaran, FALSE, 'ASC', 1);
$pembayaran = mysql_fetch_object($qpembayaran);
// post tambah
if (array_key_exists('key', $_POST)) {
    $submit_type = $_POST['submit_type'];
    // Ajax Add
    if ($submit_type == 'add_session_id_pembayaran') {
        $id_pembayaran = escape($_POST['id']);
        $_SESSION['id_pembayaran'] = $id_pembayaran;
    } elseif ($submit_type == 'add_transaksi') {
        $id_siswa = escape($_POST['id_siswa']);
        $q_siswa = get_by_id('siswa', 'id', $id_siswa, FALSE, 'ASC', 1);
        $siswa = mysql_fetch_object($q_siswa);
        $jumlah = $pembayaran->jumlah;
        // check jika siswa sudah membayar
        $q_val_cek = mysql_query("SELECT * FROM transaksi WHERE id_siswa='{$siswa->id}' AND id_pembayaran='{$id_pembayaran}'");
        if (mysql_num_rows($q_val_cek) == 0) {
            // jika saldo tidak mencukupi
            if ($siswa->saldo < $jumlah) {
                $error = 'Saldo tidak Mencukupi';
            } else {
                $saldo_akhir = $siswa->saldo - $jumlah;
                $kode = hash('crc32', now() . $id_siswa . $id_pembayaran);
                $q_t_pembayaran = sprintf("INSERT INTO transaksi(kode, tipe, jumlah, id_siswa, id_pembayaran, saldo_akhir, id_guru, tanggal, created_at)\n                                        VALUES('%s', '%s', '%d', '%s','%s', '%s', '%s', '%s', '%s')", $kode, 'out', $jumlah, $id_siswa, $id_pembayaran, $saldo_akhir, $_SESSION['logged_id'], now(), now());
                $r_t_pembayaran = mysql_query($q_t_pembayaran);
                $q_update_saldo_siswa = mysql_query("UPDATE siswa SET saldo='{$saldo_akhir}' WHERE id='{$id_siswa}'");
                $error = 'Berhasil Transaksi';
示例#6
0
?>
	<?php 
if (isset($_GET['aid']) and get_by_id($_GET['aid'], "aname")) {
}
?>
	<div class="container">
		<form action="">
			<div class="form-group">
				<h3 class="activity-name">
					<?php 
echo get_by_id($_GET['aid'], "aname");
?>
				</h3>
				<p class="activity-limit">
					参加人数 <?php 
echo get_by_id($_GET['aid'], "acur") . " / " . get_by_id($_GET['aid'], "alimit");
?>
				<p>
				<input type="hidden" name="aid" value="<?php 
echo $_GET['aid'];
?>
">
			</div>
			<div class="form-group"><label for="id">学号</label><input type="text" class="form-control" name="id"></div>
			<div class="form-group"><label for="name">姓名</label><input type="text" class="form-control" name="name"></div>
			<input type="submit" class="btn btn-success form-control">
		</form>
	</div>
	<?php 
?>
</body>
示例#7
0
<html>
    <head>
        <link rel="stylesheet" href="css/bootstrap.min.css"/>

        <title>BanManagement - Ban</title>
    </head>

    <body>
        <?php 
require "api/api.php";
require "header.php";
$ban = get_by_id($_GET["id"]);
?>

        <div class="jumbotron">
            <div class="container">
                <h1>Ban #<?php 
echo $ban["id"];
?>
</h1>
            </div>
        </div>

        <div class="container">
            <?php 
if (isset($_SESSION["username"])) {
    ?>
                <div class="col-lg-2">
                    <div class="panel panel-warning">
                        <div class="panel-heading">Manage</div>
                        <div class="panel-body">
示例#8
0
function do_signup($aid, $id, $name)
{
    global $conn;
    $conn->insert('activities_sign', ['aid', 'sid', 'name'], [htmlspecialchars($aid), htmlspecialchars($id), htmlspecialchars($name)]);
    $conn->update('activities', ['acur'], [get_by_id($aid, 'acur') + 1], "id = " . htmlspecialchars($aid));
}