Jumat, 18 Oktober 2013

PHP Indonesia - Facebook: gan kok gak ke update ya gan

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Refresh your vocabulary.

Learn a new word everyday by subscribing to Word of the Day. A great tool if you're studying for the GRE, GMAT or LSAT, or simply want to enhance your lexicon.
From our sponsors
gan kok gak ke update ya gan
Oct 18th 2013, 15:19, by Danny Widhianto

Danny Widhianto 3:19pm Oct 18
gan kok gak ke update ya gan

<?php
require '../../Koneksi.php';

$id = null;
if ( !empty($_GET['id'])) {
$id = $_REQUEST['id'];
}

if ( null==$id ) {
header("Location: ../../Daftarmenu.php");
}

if ( !empty($_POST)) {
// keep track validation errors
$labelError = null;
$linkError = null;
$aktifError = null;

// keep track post values
$label = $_POST['label'];
$link = $_POST['link'];
$aktif = $_POST['aktif'];

// validate input
$valid = true;
if (empty($label)) {
$labelError = 'Tolong isikan Label';
$valid = false;
}

if (empty($link)) {
$linkError = 'Tolong isikan URL';
$valid = false;
}

if (empty($aktif)) {
$aktifError = 'Tolong pilih salah satu Y atau N';
$valid = false;
}

// update data
if ($valid) {
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE menu SET label = ?, link = ?, aktif = ? WHERE id_main = ?";
$q = $pdo->prepare($sql);
$q->execute(array($label,$link,$aktif,$id_main));
Database::disconnect();
header("Location: ../../Daftarmenu.php");
}
} else {
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM menu where id_main = ?";
$q = $pdo->prepare($sql);
$q->execute(array($id));
$data = $q->fetch(PDO::FETCH_ASSOC);
$label = $data['label'];
$link = $data['link'];
$aktif = $data['aktif'];
Database::disconnect();
}
?>

Danny Widhianto 3:22pm Oct 18
khusus action create n delete bisa gan

Gunawan Mujur Wibisono 3:26pm Oct 18
$q->execute(array($label,$link,$aktif,$id_main)); >> bukannya ada yg lain lagi?

Danny Widhianto 3:31pm Oct 18
kya gmana ya gan .... bru terjun OOP

Gunawan Mujur Wibisono 3:32pm Oct 18
itu bukan oop.. tp pdo.. coba deh pelajari sql biasa aja.. gk pake excute..

Danny Widhianto 5:31pm Oct 18
gan klo fungsi dari PDO::ERRMODE_EXCEPTION); apa ya gan

Cahya Dsn 6:00pm Oct 18
ane nanya dulu deh... '$id_main' pada:
//..
$q->execute(array($label,$link,$aktif,$id_main));
//..

itu darimana mana? kalo gini gimana?

//..
$q->execute(array($label,$link,$aktif,$id));
//..
cmiiw ^_^V

Danny Widhianto 6:02pm Oct 18
klo id_main ane ambil dari kolom id_main dari table menu gan

Cahya Dsn 6:04pm Oct 18
apakah variabel $id_main udah di deklarasikan sebelumnya? (semisal $id_main=$_GET['id_main']... atau $id_main=$_POST['id_main'] ..atau sejenisnya) re-check your code again!

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar