|
Post by along on Sept 26, 2005 2:56:24 GMT -5
Sapa2 nak kongsi ilmu pasal php atau apa2 bahasa programming boleh la kongsi di sini.
|
|
|
Post by along on Sept 27, 2005 22:00:37 GMT -5
Contoh fail enjin / index
<?
$user = new pengguna(); $delete = $user->delete_pengguna($userid); $midfile = "templates/listall_pengguna.php";
if ($_POST['action']) { $userid = $_POST['userid']; $delete = $user->delete_pengguna($userid);
if ($penggunaRes) {
} else {
}
} $select = $user->list_all_pengguna(); require $midfile;
?>
|
|
|
Post by along on Sept 27, 2005 22:02:59 GMT -5
ini class yg akan di panggil oleh fail enjin/ index diatas
class pengguna extends DB_sql {
var $table_pengguna; //constructor function pengguna() { $this->table_pengguna="pengguna"; // function ini akan dipanggil oleh fail index di atas function list_all_pengguna(){ $q="SELECT * FROM $this->table_pengguna"; $this->query($q); $j=0; if (($this->num_rows($q)) > 0 ) { while($this->next_record()) { $ret[$j] = $this->Record; $j++; } return $ret; } else { $this->Error=_("No Record Found"); return 0; } } }
|
|
|
Post by along on Sept 27, 2005 22:06:09 GMT -5
ini fail yg akan memaparkan output yg di hantar oleh fail index/ enjin
</script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>senarai pengguna</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <br> <br>
<form name=myform method=post > <table width="100%" cellspacing="1" cellpadding="1" bgcolor="#DCDCDC"> <tr bgcolor=""><font color="blue"> <td width="20%" align="center"><strong>Nama</strong></td> <td width="20%" align="center"><strong>Userid</strong></td> <td width="6%" align="center"><strong>Password</strong></td> <td width="6%" align="center"><strong>level</strong></td> <td width="5%" align="center"><strong>cawid</strong></td> <td width="5%" align="center"><strong>enable</strong></td> </font> </tr> <?for ($i=0;$i<count($select);$i++){?> <tr align="center"> <td><?=$select[$i]['name']?></td> <td><?=$select[$i]['userid']?></td> <td><?=$select[$i]['passwd']?></td> <td><?=$select[$i]['level']?></td> <td><?=$select[$i]['cawid']?></td> <td><?=$select[$i]['enable']?></td> <?}?> <input type=hidden name=userid> <input type=hidden name=action value=1>
</form>
</body> </html>
|
|
|
Post by along on Oct 12, 2005 21:20:22 GMT -5
Cara utk select drpd database utk di paparkan pada selecbox : <tr> <td><div align="right">Negeri : <td colspan="4"> <select name ="negeri" class="inputbox"> <? for ($i=0; $i<count($list_negeri); $i++) { if ($list_negeri[$i]['keterangan']=="Terengganu") echo "<option selected value=".$list_negeri[$i]['kod'].">".$list_negeri[$i]['keterangan']." </option>"; else echo "<option value=".$list_negeri[$i]['kod'].">".$list_negeri[$i]['keterangan']." </option>"; } ?>
</select> <tr>
|
|
|
Post by along on Nov 10, 2005 0:18:05 GMT -5
check range in DB
---------------------------------------------------------------------
case "add_upahsimpan" : if($_POST['action2']){
$min_hut = $_POST['minhutang']; $mak_hut = $_POST['makhutang'];
$min_huts = $_POST['min_hut']; $max_huts = $_POST['max_hut'];
$_up = $upahsimpan_Obj->list_upahsimpan($id);
for($i=0;$i<count($_up);$i++){ //echo "min = ".$_up[$i]['minhutang']." max = ".$_up[$i]['makhutang']."<br>"; if (($min_hut >= $_up[$i]['minhutang']) && ($mak_hut <= $_up[$i]['makhutang']) || ($mak_hut >= $_up[$i]['makhutang']) && ($mak_hut <= $_up[$i]['makhutang']) || ($min_hut >= $_up[$i]['minhutang']) && ($min_hut <= $_up[$i]['minhutang'])){ $_next = 0; $i=count($_up); } //echo "tak <br>"; else { $_next=1; } }
if($_next==1) $result=$upahsimpan_Obj->insert_upahsimpan($_POST['id'], $_POST['minhutang'], $_POST['makhutang'], $_POST['upahsimpan']); if ($result){ $sysmsg='Tambah upah simpan telah berjaya'; }else{ $sysmsg='Range telah wujud'; }
$action="";
//else //echo "mana leh"; } //$min_hut=$_POST['min_hut'] - //$max_hut=$_POST['max_hut'];
$midbody = 'templates/add_upahsimpan.php';
|
|
|
Post by along on Nov 19, 2005 22:30:09 GMT -5
--------------------------------------
case "add_upahsimpan" : if($_POST['action2']){ $min_hut = $_POST['minhutang']; $mak_hut = $_POST['makhutang'];
$_up = $upahsimpan_Obj->list_upahsimpan($id ,$minhutang, $makhutang, $upahsimpan);
for($i=0;$i<count($_up);$i++){ // echo "min = ".$_up[$i]['minhutang']." max = ".$_up[$i]['makhutang']."<br>"; if (($min_hut >= $_up[$i]['minhutang']) && ($mak_hut <= $_up[$i]['makhutang']) || ($min_hut >= $_up[$i]['minhutang']) && ($min_hut <= $_up[$i]['makhutang']) || ($mak_hut >= $_up[$i]['minhutang']) && ($mak_hut <= $_up[$i]['makhutang'])) { $_next = 0; $i=count($_up); } //echo "tak <br>"; else { $_next=1; } }
if($_next==1)
$result=$upahsimpan_Obj->insert_upahsimpan($_POST['id'], $_POST['minhutang'], $_POST['makhutang'], $_POST['upahsimpan']); if ($result){ $sysmsg='Tambah upah simpan telah berjaya'; }else{ $sysmsg='Range telah wujud'; }
$action="";
|
|
|
Post by along on Nov 25, 2005 23:49:30 GMT -5
-------------------------------------- $midbody = 'templates/add_jenismarhun.php';
if ($_POST['action2']) {
$cek_jenismarhum = $jenismarhun_Obj->check_jenismarhun($_POST['kod']); if (!$cek_jenismarhum) { $result = $jenismarhun_Obj->tambah_jenismarhun($_POST['kod'], $_POST['keterangan']); if ($result) $sysmsg='Tambah jenis marhun telah berjaya'; else $sysmsg='Tambah jenis marhun gagal'; } else { $sysmsg='kod jenis marhun telah wujud'; }
$action=""; }
break;
|
|