CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

Author: bender

tumpang tanye psl html n php

[Copy link]
Post time 26-3-2009 06:18 AM | Show all posts
--cancel--

[ Last edited by  cloud_hardcore at 26-3-2009 06:21 ]
Reply

Use magic Report


ADVERTISEMENT


Post time 26-3-2009 06:20 AM | Show all posts
--cancel--

[ Last edited by  cloud_hardcore at 26-3-2009 06:22 ]
Reply

Use magic Report

Post time 26-3-2009 06:21 AM | Show all posts
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..??
Reply

Use magic Report

Post time 26-3-2009 06:22 AM | Show all posts
--cancel--
Reply

Use magic Report

Post time 26-3-2009 08:15 AM | Show all posts
ko guna array

mula kat form ko... set setiap field as array cth
  1. <input type="hiddent" name="student_id[]" value="<?= $row['student_id'] ?>">

  2. <input type="text" name="kuiz1[]">
  3. <input type="text" name="kuiz2[]">
  4. <input type="text" name="test1[]">
  5. <input type="text" name="test2[]">
Copy the Code


n masa nk insert ke database
  1. <?
  2. for($i=0; $i<count($_POST['student_id']); $i++){
  3. 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] ."')");
  4. }
  5. ?>
Copy the Code
Reply

Use magic Report

Post time 26-3-2009 03:14 PM | Show all posts

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.??
Reply

Use magic Report

Follow Us
Post time 26-3-2009 03:16 PM | Show all posts
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...
Reply

Use magic Report

Post time 28-3-2009 10:50 PM | Show all posts

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">&nbsp;</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
Reply

Use magic Report


ADVERTISEMENT


Post time 28-3-2009 11:36 PM | Show all posts
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

Use magic Report

Post time 29-3-2009 01:35 AM | Show all posts

Reply #208 cloud_hardcore's post

ko leh buat javascript validate or php validate
n contoh php validate
  1. <?php
  2. include('configure.php');
  3. $idibubapa                                        =$_REQUEST['idibubapa'];
  4. $nama                                                =$_REQUEST['nama'];
  5. $ic                                                =$_REQUEST['ic'];
  6. $alamat                                                =$_REQUEST['alamat'];
  7. $katalaluan                                        =$_REQUEST['katalaluan'];

  8. if(!is_numeric($ic))
  9.    $error = "Please insert number only!";
  10. else
  11. {
  12. $sql1 ="SELECT * from ibubapa WHERE IDibubapa = '$idibubapa'";
  13.         $result1 = mysql_query($sql1);
  14.         if (!$result1) {
  15.                 echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
  16.         exit;
  17.         }
  18.         else {
  19.         $row1 = mysql_fetch_assoc($result1);
  20.         $count=mysql_num_rows($result1);
  21.         //echo $count;
  22.         
  23. if($count==1){
  24. echo "ID Penjaga telah digunakan:";
  25. }

  26. else {
  27. $query1="insert into ibubapa(IDibubapa,nama,ic,alamat,katalaluan)  values('$idibubapa','$nama','$ic','$alamat','$katalaluan')";
  28. mysql_db_query($dbname, $query1);
  29. //echo"$query1";
  30. echo "Rekod Berjaya Ditambah !<br>";
  31. }}
  32. ?>
Copy the Code

[ Last edited by  BorderManager at 29-3-2009 01:36 ]
Reply

Use magic Report

Post time 29-3-2009 01:39 AM | Show all posts
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
Reply

Use magic Report

Post time 29-3-2009 10:14 AM | Show all posts

Balas #211 BorderManager\ catat

ok dh solve..thx..
Reply

Use magic Report

Post time 31-3-2009 01:32 AM | Show all posts
board...yg function delete niee....cane nak delete kalo dlm DB aku set as BIGINT not INT...sbb xleh delete..

if(isset($_REQUEST['delete'])){
&#160; &#160; if(sizeof($_POST['chkbx'])){
&#160; &#160;&#160; &#160;&#160;&#160;foreach($_POST['chkbx'] AS $val){
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $val=intval(000000000000);
&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;&#160;$sql = mysql_query("DELETE FROM $tbl_name WHERE nokp=".(int)$val)or die(mysql_error());
&#160; &#160;&#160; &#160;&#160;&#160;}
&#160; &#160; }
&#160; &#160;
&#160; &#160; // if successful redirect to delete_multiple.php
&#160; &#160; if($sql){
&#160; &#160;&#160; &#160;&#160;&#160;echo "";
&#160; &#160; }
}
Reply

Use magic Report

Post time 1-4-2009 08:43 PM | Show all posts
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
Reply

Use magic Report

Post time 2-4-2009 10:33 AM | Show all posts
ooo..ok..dah jadi..int tu aku tukarkan string baru dier leh hapus data yg bigint..kalo aku isi int je dier takleh delete..
Reply

Use magic Report

Post time 12-4-2009 06:46 PM | Show all posts
Guna Dynamic HTML.. banyak kat luar sana..
Reply

Use magic Report


ADVERTISEMENT


You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

10-1-2025 05:14 AM GMT+8 , Processed in 0.042770 second(s), 24 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list