Results 1 to 8 of 8

Thread: camna nak delete guna check box

  1. #1
    Join Date
    Mar 2002
    Posts
    5
    Rep Power
    0

    Unhappy camna nak delete guna check box

    aloo, kengkawan aku ada problem skit nih, camna nak buat delete guna check box cam dalam email tula, aku guna php4.0.5 ngan database mysql, kalu nak delete satu2 tu tau la aku ,,tolong yoo kengkawang kalu buleh bagila contoh yang lengkap siap nagn coding dio..

  2. #2
    Join Date
    Aug 2001
    Location
    Ampang KL
    Posts
    93
    Rep Power
    227

    The Solution

    Pertama sekali, gukana id yang unik untuk setai value checkbox dan berikan FORM NAME yang berakhiran dengan [] , contohnya padam[]

    Sila lihat contoh di bawah :

    PHP Code:
    <!-- padam.html -->
    <form action="padam.php" method="post">

    <input type="checkbox" name="padam[]" value="1">
    <input type="checkbox" name="padam[]" value="2">
    <input type="checkbox" name="padam[]" value="3">
    <input type="checkbox" name="padam[]" value="4">
    <input type="checkbox" name="padam[]" value="5">
    <input type="checkbox" name="padam[]" value="6">

    <input type="submit" value="Padam">
    </form>


    <?
    // 
    // padam.php
    // Proses fail untuk padam.html
    //

    /* check $padam adalah array */
    if(is_array($padam))
    {
       
        
    /* gunakan foreach untuk print nilai padam */

        
    foreach($padam as $data)
        {
             echo 
    $data;
             echo 
    "<br>";
            
    /* Buat proses pemadaman di sini */
         
    }

    } else {
       echo 
    " Tiada Data Dipilih ";
    }

    ?>

  3. #3
    Join Date
    Mar 2002
    Posts
    5
    Rep Power
    0
    thank bazet, tapi... ni contoh coding aku<?php
    $db = mysql_connect("localhost", "");
    mysql_select_db("sukns",$db);
    $result = mysql_query("SELECT * FROM aduan ORDER BY nama ASC",$db);
    $num = mysql_numrows($result);
    ?> </p>

    <form method="post" action="cobaan3.php4">
    <?
    echo "<TABLE BORDER=2>";
    while ($myrow = mysql_fetch_array($result))

    {
    echo "<TR><TD>";
    echo $myrow["hari"];
    echo "/";
    echo $myrow["bulan"];
    echo "/";
    echo $myrow["tahun"];
    echo "<TD>";
    echo $myrow["nama"];
    echo "<TD>";
    echo $myrow["jabatan"];
    echo "<TD>";
    echo $myrow["no_tel"];
    echo "<TD>";
    echo $myrow["jenis"];
    echo "<TD>";
    echo $myrow["tek_staf"];
    echo "<TD>";

    ?>
    <td>

    <input type="checkbox" name="del[<? echo $num ?>]" value="on">

    </td>

    <?
    }
    echo "</TABLE>";

    ?>

    coding ni akan papar nilai data dalam database ngan check box kat ujung setiap table tu so camna aku nak padam bila aku tanda check yang ada kat ujung dia tu..
    bule ker guna method diatas , tolong yo bazet

  4. #4
    Join Date
    Aug 2001
    Location
    Ampang KL
    Posts
    93
    Rep Power
    227
    Ohh listing pun awak guna PHP yerk

    senang aja,,,just assign unik id untuk setiap checkbox

    cth

    user : mazreha
    id : 1

    user : azril
    id =2

    user : imaz
    id =3

    HTML awak akan berbetuk cam gini
    PHP Code:
    Mazreha = <input type="checkbox" name="nama[]" id="1">
    <
    br>
    Azril = <input type="checkbox" name="nama[]" id="2">
    <
    br>
    Imaz = <input type="checkbox" name="nama[]" id="3"
    so, bila user submit, function foreach() akan mengambil nilai id $name dan awak lakukan SQl delete dalam loop

  5. #5
    Join Date
    Mar 2002
    Location
    -
    Posts
    16
    Rep Power
    0
    akum, tu kalu utk 1 button delete jer, kalu bayk button lak camner?cth nyer ader button edit, delete & update camenr(mcm dlm geocities->file manager) tu lah.harap dpt bantu

  6. #6
    Join Date
    Mar 2002
    Posts
    5
    Rep Power
    0
    okey masa masa ko papar data dari database tu ko taruk sekali satu button delete kat situ yang mewakili data base tu
    cam niecho
    <a href=\"delete.php?id=".$myrow[primary key dari database]."\">button delete</a>
    aaaa lepaih tu ko buleh la buat function delete kat delete.php
    tu lakot
    saya budak baru belajar kalu salah tolong tunjukkan...

  7. #7
    Join Date
    Mar 2002
    Posts
    5
    Rep Power
    0
    thank bazet, ianya berjalan seperti yang diharapkan...
    mana ko belajar php ni ha.. terer semacam jer, sebenonya, aku ni tgh praktikal kat satu kompeni, diorang suruh aku buat satu aplikasi pakai php tu yang letih tu pasal aku takde banyak engalaman sgat tu, aku nak mintak sedikit tunjuk ajar dari ko..

  8. #8
    Join Date
    Mar 2002
    Location
    -
    Posts
    16
    Rep Power
    0
    akum, saya pun nak tanya gak sesaper yg ilmu lebih la....
    tu kalu nok delete so 1 function jer, katakan kalu kener wat 3 function serentak, cthnyer, delete, edit, & add.Boleh tak korang bg idea & coding nyer nan complete.Senang nak rujuk.

    -----------------------------------------------------------------
    minda yang kecil membincangkan manusia
    minda yang sederhana membincangkan peristiwa
    minda yang besar membincangkan idea


    <!--BabY MEraNGkaK-->

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How delete post?Im new here!
    By xblue_skyx in forum Mamak Stall
    Replies: 6
    Last Post: 01-11-2007, 02:06 PM
  2. Camna nak sharing PC kat office
    By nadzyie in forum Mamak Stall
    Replies: 0
    Last Post: 15-08-2003, 01:39 AM
  3. camna nak install postnuke dlm server
    By Rezats in forum Website Programming
    Replies: 17
    Last Post: 01-05-2002, 11:49 AM
  4. camna nak buat kalendar...
    By pikachu78 in forum Website Programming
    Replies: 1
    Last Post: 24-04-2002, 05:00 PM
  5. camner nak wat delete/edit/update gunakan check box
    By nuha in forum Website Programming
    Replies: 1
    Last Post: 23-04-2002, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113