|
--cancel--
[ Last edited by cloud_hardcore at 26-3-2009 06:21 ] |
|
|
|
|
|
|
|
--cancel--
[ Last edited by cloud_hardcore at 26-3-2009 06:22 ] |
|
|
|
|
|
|
|
aku tompang tread ko la erk tuan rumah...
alkesah nye begini
.............
Table belajar
IDbelajar IDsubjek IDpelajar
---------------------------------------------
1 BIT2011 AI050149
2 BIT2011 AI050150
3 BIT2011 AI050153
Table Penilaian
IDpenilaian IDsubjek Nama_penilaian
----------------------------------------------------
1 BIT2011 Kuiz1
2 BIT2011 Kuiz2
3 BIT2011 Test1
4 BIT2011 Test2
5 BIT2011 Kelakuan
----------------------------------------------------------------------------------------------------------
Apabila tekan butang submit akan masuk table mpenilaian.
Table Mpenilaian
IDmpenilaian IDpenilaian markah
p/s: penilaian dan pelajar(eg. AI050150) akan berubah-ubah mengikut subjek.
bahasa:php
db:mysql
soalan
1.bagaimana utk menjadikan form seperti gambar tersebut..??
2.bagaimana proses untuk insert ke dlm database..?? |
|
|
|
|
|
|
|
ko guna array
mula kat form ko... set setiap field as array cth- <input type="hiddent" name="student_id[]" value="<?= $row['student_id'] ?>">
- <input type="text" name="kuiz1[]">
- <input type="text" name="kuiz2[]">
- <input type="text" name="test1[]">
- <input type="text" name="test2[]">
Copy the Code
n masa nk insert ke database- <?
- for($i=0; $i<count($_POST['student_id']); $i++){
- mysql_query("INSERT INTO mpenilaian (id_pelajar, kuiz1, kuiz2, test1, test2) VALUES ('". $_POST['student_id'][$i] ."','". $_POST['kuiz1'][$i] ."','". $_POST['kuiz2'][$i] ."','". $_POST['test1'][$i] ."','". $_POST['test2'][$i] ."')");
- }
- ?>
Copy the Code |
|
|
|
|
|
|
|
Balas #205 BorderManager\ catat
masalah nye..untuk kuiz 1,kuiz 2 etc...tidak tetap..klu mmg btol2 ade 6 jenis je or tetap xkesah..ni klu subjek laen myb de 4 jenis je..camne tu.?? |
|
|
|
|
|
|
|
INSERT INTO mpenilaian (id_pelajar, kuiz1, kuiz2, test1, test2)-->xley..
sbb dlm mpenilaian table die (idmpenilaian,id penilaian,markah)
bende yg di isi dlm kuiz1,test sume tu akan duk dlm colum markah... |
|
|
|
|
|
|
|
nk tye lg..
ni form aku..
ni lak koding form
===============================================
<form method="post" action="proses_daftaribubapa.php">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">ID Penjaga:</td>
<td>
<input type="text" name="idibubapa" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nama Penjaga:</td>
<td><input type="text" name="nama" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">No Kad Pengenalan </td>
<td><input name="ic" type="int" size="12"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Alamat</td>
<td><textarea name="alamat" cols="28"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Katalaluan:</td>
<td><input type="text" name="katalaluan" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input name="submit" type="submit" value="Simpan dan Seterusnya">
<input type="submit" name="Submit" value="Semula"></td>
</tr>
</table>
</form>
===============================================
ni lak koding proses insert die
===============================================
<?php
include('configure.php');
$idibubapa =$_REQUEST['idibubapa'];
$nama =$_REQUEST['nama'];
$ic =$_REQUEST['ic'];
$alamat =$_REQUEST['alamat'];
$katalaluan =$_REQUEST['katalaluan'];
$sql1 ="SELECT * from ibubapa WHERE IDibubapa = '$idibubapa'";
$result1 = mysql_query($sql1);
if (!$result1) {
echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
exit;
}
else {
$row1 = mysql_fetch_assoc($result1);
$count=mysql_num_rows($result1);
//echo $count;
if($count==1){
echo "ID Penjaga telah digunakan:";
}
else {
$query1="insert into ibubapa(IDibubapa,nama,ic,alamat,katalaluan) values('$idibubapa','$nama','$ic','$alamat','$katalaluan')";
mysql_db_query($dbname, $query1);
//echo"$query1";
echo "Rekod Berjaya Ditambah !<br>";
}
?>
<a href="form_daftaribubapa.php"><strong>[Daftar Penjaga?]</strong></a>
<?php }}?> atau
<a href="senaraiibubapa.php"><strong>[Lihat Senarai Penjaga?]</strong></a>
===============================================
soalan nye..
1)ic or kad pengenalan sptt nye nombor...tp klu isi abjad gak proses tetap berjalan tanpa memberi warning...then aku nk wat cmne klu pengguna tu isi abjad akan kuar warning...tq |
|
|
|
|
|
|
|
minta tlg checkkan..
<?php
session_start();
include ('db_config.php');
$username = $_POST['username'];
$password = $_POST['password'];
$user = "SELECT * FROM user WHERE username='$username' && password='$password'";
$result_user = mysql_query($user);
if ($row = mysql_fetch_array($result_user))
{
session_register('nama');
$_SESSION['nama'] = $result_user['name'];
if ($row['group'] == 'admin')
{
header("location:index_admin.php");
exit ;
}
elseif ($row['group'] == 'lecturer')
{
header("location:index_lecturer.php");
exit ;
}
elseif ($row['group'] == 'driver')
{
header("location:index_driver.php");
exit ;
}
}
else
{
echo "Wrong Username or Password";
}
?>
knape kalo * tu aku gntikan nama column kluar error :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\finalproject\login_process.php on line 11
Wrong Username or Password |
|
|
|
|
|
|
|
Reply #208 cloud_hardcore's post
ko leh buat javascript validate or php validate
n contoh php validate
- <?php
- include('configure.php');
- $idibubapa =$_REQUEST['idibubapa'];
- $nama =$_REQUEST['nama'];
- $ic =$_REQUEST['ic'];
- $alamat =$_REQUEST['alamat'];
- $katalaluan =$_REQUEST['katalaluan'];
- if(!is_numeric($ic))
- $error = "Please insert number only!";
- else
- {
- $sql1 ="SELECT * from ibubapa WHERE IDibubapa = '$idibubapa'";
- $result1 = mysql_query($sql1);
- if (!$result1) {
- echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
- exit;
- }
- else {
- $row1 = mysql_fetch_assoc($result1);
- $count=mysql_num_rows($result1);
- //echo $count;
-
- if($count==1){
- echo "ID Penjaga telah digunakan:";
- }
- else {
- $query1="insert into ibubapa(IDibubapa,nama,ic,alamat,katalaluan) values('$idibubapa','$nama','$ic','$alamat','$katalaluan')";
- mysql_db_query($dbname, $query1);
- //echo"$query1";
- echo "Rekod Berjaya Ditambah !<br>";
- }}
- ?>
Copy the Code
[ Last edited by BorderManager at 29-3-2009 01:36 ] |
|
|
|
|
|
|
|
knape kalo * tu aku gntikan nama column kluar error :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQLresult resource in D:\xampp\htdocs\finalproject\login_process.php online 11
Wrong Username or Password
cuba ko letak tanda n `
select `user` from table,
ada setengah field yg digunakan dlm mysql function seperti
user, group, option, dll |
|
|
|
|
|
|
|
Balas #211 BorderManager\ catat
|
|
|
|
|
|
|
board...yg function delete niee....cane nak delete kalo dlm DB aku set as BIGINT not INT...sbb xleh delete..
if(isset($_REQUEST['delete'])){
    if(sizeof($_POST['chkbx'])){
        foreach($_POST['chkbx'] AS $val){
                $val=intval(000000000000);
              $sql = mysql_query("DELETE FROM $tbl_name WHERE nokp=".(int)$val)or die(mysql_error());
        }
    }
   
    // if successful redirect to delete_multiple.php
    if($sql){
        echo "";
    }
} |
|
|
|
|
|
|
|
xda beza pn klu BigInt atau Int
beza dr segi size storan dia aja
big int boleh simpan nilai sampai berbelas angka klu int plak up to 7 angka
klu x silap aku la
so that mean,ko ada prob dengan kod ko |
|
|
|
|
|
|
|
ooo..ok..dah jadi..int tu aku tukarkan string baru dier leh hapus data yg bigint..kalo aku isi int je dier takleh delete.. |
|
|
|
|
|
|
|
Guna Dynamic HTML.. banyak kat luar sana.. |
|
|
|
|
|
|
| |
|