Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    MySQL Updating using HTML form and PHP

    I'm now trying to update data using a form, this is the update script. Unfortunately the things I update do not take effect. Everything else stays the same though.

    Code:
        <?php
        if(isset($_POST['update']))
        {
        $con = mysql_connect("localhost","username","password");
        if (!$con) {
                die('Could not connect: ' . mysql_error());
        }
         
        $id = $_POST['id'];
        $soditemid = $_POST['soditemid'];
        $tier = $_POST['Tier'];
        $itemname = $_POST['ItemName'];
        $itemac = $_POST['AC'];
        $itemstr = $_POST['STR'];
        $itemsta = $_POST['STA'];
        $itemdex = $_POST['DEX'];
        $itemagi = $_POST['AGI'];
        $itemcha = $_POST['CHA'];
        $itemwis = $_POST['WIS'];
        $itemint = $_POST['INT'];
        $itemhp = $_POST['HP'];
        $itemmana = $_POST['Mana'];
        $itemmr = $_POST['MR'];
        $itemfr = $_POST['FR'];
        $itemcr = $_POST['CR'];
        $itempr = $_POST['PR'];
        $itemdr = $_POST['DR'];
        $itemft = $_POST['FT'];
        $itemcs = $_POST['CS'];
        $itemms = $_POST['MS'];
        $itemsr = $_POST['SR'];
        $itemdmgr = $_POST['DmgR'];
        $itemaggr = $_POST['Aggr'];
        $itemsw = $_POST['SpellWard'];
        $instrument = $_POST['Instrument'];
        $instrumentmod = $_POST['InstrumentMod'];
        $banetype = $_POST['BaneType'];
        $banedmg = $_POST['BaneDmg'];
        $skillmod = $_POST['SkillMod'];
        $skillmodamt = $_POST['SkillModAmt'];
        $focuseffect = $_POST['FocusEffect'];
        $spelleffect = $_POST['SpellEffect'];
        $weapondmg = $_POST['WeaponDmg'];
        $weapondly = $_POST['WeaponDly'];
        $weapontype = $_POST['WeaponType'];
        $earslot = $_POST['earslot'];
        $neckslot = $_POST['neckslot'];
        $headslot = $_POST['headslot'];
        $faceslot = $_POST['faceslot'];
        $chestslot = $_POST['chestslot'];
        $backslot = $_POST['backslot'];
        $armslot = $_POST['armslot'];
        $shoulderslot = $_POST['shoulderslot'];
        $wristslot = $_POST['wristslot'];
        $waistslot = $_POST['waistslot'];
        $handslot = $_POST['handslot'];
        $fingerslot = $_POST['fingerslot'];
        $legslot = $_POST['legslot'];
        $feetslot = $_POST['feetslot'];
        $prislot = $_POST['prislot'];
        $secslot = $_POST['secslot'];
        $rangeslot = $_POST['rangeslot'];
        $ammoslot = $_POST['ammoslot'];
        $charmslot = $_POST['charmslot'];
        $aug2slot = $_POST['aug2slot'];
        $aug3slot = $_POST['aug3slot'];
        $aug5slot = $_POST['aug5slot'];
        $mob = $_POST['mob'];
        $brdclass = $_POST['brdclass'];
        $bstclass = $_POST['bstclass'];
        $clrclass = $_POST['clrclass'];
        $druclass = $_POST['druclass'];
        $encclass = $_POST['encclass'];
        $magclass = $_POST['magclass'];
        $mnkclass = $_POST['mnkclass'];
        $necclass = $_POST['necclass'];
        $palclass = $_POST['palclass'];
        $rngclass = $_POST['rngclass'];
        $rogclass = $_POST['rogclass'];
        $shdclass = $_POST['shdclass'];
        $shmclass = $_POST['shmclass'];
        $warclass = $_POST['warclass'];
        $wizclass = $_POST['wizclass'];
        mysql_select_db("ketocon_quila", $con);
        mysql_query(    "UPDATE Items2 SET soditemid = '$soditemid',
                                        Tier = '$tier',
                                        ItemName = '$itemname',
                                        AC = '$itemac',
                                        STR = '$itemstr',
                                        STA = '$itemsta',
                                        DEX = '$itemdex',
                                        AGI = '$itemagi',
                                        CHA = '$itemcha',
                                        WIS = '$itemwis',
                                        `INT` = '$itemint',
                                        HP = '$itemhp',
                                        Mana = '$itemmana',
                                        MR = '$itemmr',
                                        FR = '$itemfr',
                                        CR = '$itemcr',
                                        PR = '$itempr',
                                        DR = '$itemdr',
                                        FT = '$itemft',
                                        CS = '$itemcs',
                                        MS = '$itemms',
                                        SR = '$itemsr',
                                        DmgR = '$itemdmgr',
                                        Aggr = '$itemaggr',
                                        SpellWard = '$itemsw',
                                        Instrument = '$instrument',
                                        InstrumentMod = '$instrumentmod',
                                        BaneType = '$banetype',
                                        BaneDmg = '$banedmg',
                                        SkillMod = '$skillmod',
                                        SkillModAmt = '$skillmodamt',
                                        FocusEffect = '$focuseffect',
                                        SpellEffect = '$spelleffect',
                                        WeaponDmg = '$weapondmg',
                                        WeaponDly = '$weapondly',
                                        WeaponType = '$weapontype',
                                        earslot = '$earslot',
                                        neckslot = '$neckslot',
                                        headslot = '$headslot',
                                        faceslot = '$faceslot',
                                        chestslot = '$chestslot',
                                        backslot = '$backslot',
                                        armslot = '$armslot',
                                        shoulderslot = '$shoulderslot',
                                        wristslot = '$wristslot',
                                        waistslot = '$waistslot',
                                        handslot = '$handslot',
                                        fingerslot = '$fingerslot',
                                        legslot = '$legslot',
                                        feetslot = '$feetslot',
                                        prislot = '$prislot',
                                        secslot = '$secslot',
                                        rangeslot = '$rangeslot',
                                        ammoslot = '$ammoslot',
                                        charmslot = '$charmslot',
                                        aug2slot = '$aug2slot',
                                        aug3slot = '$aug3slot',
                                        aug5slot = '$aug5slot',
                                        mob = '$mob',
                                        brdclass = '$brdclass',
                                        bstclass = '$bstclass',
                                        clrclass = '$clrclass',
                                        druclass = '$druclass',
                                        encclass = '$encclass',
                                        magclass = '$magclass',
                                        mnkclass = '$mnkclass',
                                        necclass = '$necclass',
                                        palclass = '$palclass',
                                        rngclass = '$rngclass',
                                        rogclass = '$rogclass',
                                        shdclass = '$shdclass',
                                        shmclass = '$shmclass',
                                        warclass = '$warclass',
                                        wizclass = '$wizclass'
                                        WHERE id = '$id'") or die('Error updating; ' . mysql_error());
         
         
         
        echo "Updated data successfully\n";
        mysql_close($con);
        }
        ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    What do you get when you echo your query, like
    PHP Code:
    echo "UPDATE Items2 SET soditemid = '$soditemid',
                                        Tier = '$tier',
                                        ItemName = '$itemname',
                                        AC = '$itemac',
                                        STR = '$itemstr',
                                        STA = '$itemsta',
                                        DEX = '$itemdex',
                                        AGI = '$itemagi',
                                        CHA = '$itemcha',
                                        WIS = '$itemwis',
                                        `INT` = '$itemint',
                                        HP = '$itemhp',
                                        Mana = '$itemmana',
                                        MR = '$itemmr',
                                        FR = '$itemfr',
                                        CR = '$itemcr',
                                        PR = '$itempr',
                                        DR = '$itemdr',
                                        FT = '$itemft',
                                        CS = '$itemcs',
                                        MS = '$itemms',
                                        SR = '$itemsr',
                                        DmgR = '$itemdmgr',
                                        Aggr = '$itemaggr',
                                        SpellWard = '$itemsw',
                                        Instrument = '$instrument',
                                        InstrumentMod = '$instrumentmod',
                                        BaneType = '$banetype',
                                        BaneDmg = '$banedmg',
                                        SkillMod = '$skillmod',
                                        SkillModAmt = '$skillmodamt',
                                        FocusEffect = '$focuseffect',
                                        SpellEffect = '$spelleffect',
                                        WeaponDmg = '$weapondmg',
                                        WeaponDly = '$weapondly',
                                        WeaponType = '$weapontype',
                                        earslot = '$earslot',
                                        neckslot = '$neckslot',
                                        headslot = '$headslot',
                                        faceslot = '$faceslot',
                                        chestslot = '$chestslot',
                                        backslot = '$backslot',
                                        armslot = '$armslot',
                                        shoulderslot = '$shoulderslot',
                                        wristslot = '$wristslot',
                                        waistslot = '$waistslot',
                                        handslot = '$handslot',
                                        fingerslot = '$fingerslot',
                                        legslot = '$legslot',
                                        feetslot = '$feetslot',
                                        prislot = '$prislot',
                                        secslot = '$secslot',
                                        rangeslot = '$rangeslot',
                                        ammoslot = '$ammoslot',
                                        charmslot = '$charmslot',
                                        aug2slot = '$aug2slot',
                                        aug3slot = '$aug3slot',
                                        aug5slot = '$aug5slot',
                                        mob = '$mob',
                                        brdclass = '$brdclass',
                                        bstclass = '$bstclass',
                                        clrclass = '$clrclass',
                                        druclass = '$druclass',
                                        encclass = '$encclass',
                                        magclass = '$magclass',
                                        mnkclass = '$mnkclass',
                                        necclass = '$necclass',
                                        palclass = '$palclass',
                                        rngclass = '$rngclass',
                                        rogclass = '$rogclass',
                                        shdclass = '$shdclass',
                                        shmclass = '$shmclass',
                                        warclass = '$warclass',
                                        wizclass = '$wizclass'
                                        WHERE id = $id "

    PS: You shouldn't add quotes around values inserting into numeric columns like int,float etc.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Iggy0828 (09-25-2012)

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I get this:

    Code:
    UPDATE Items2 SET soditemid = '0', Tier = '', ItemName = '', AC = '', STR = '', STA = '', DEX = '', AGI = '', CHA = '', WIS = '', `INT` = '', HP = '', Mana = '', MR = '', FR = '', CR = '', PR = '', DR = '', FT = '', CS = '', MS = '', SR = '', DmgR = '', Aggr = '', SpellWard = '', Instrument = '', InstrumentMod = '', BaneType = '', BaneDmg = '', SkillMod = '', SkillModAmt = '', FocusEffect = '', SpellEffect = '', WeaponDmg = '', WeaponDly = '', WeaponType = '', earslot = '', neckslot = '', headslot = '', faceslot = '', chestslot = '', backslot = '', armslot = '', shoulderslot = '', wristslot = 'on', waistslot = '', handslot = 'on', fingerslot = '', legslot = '', feetslot = '', prislot = '', secslot = '', rangeslot = '', ammoslot = '', charmslot = '', aug2slot = 'on', aug3slot = 'on', aug5slot = '', mob = '', brdclass = '', bstclass = 'on', clrclass = '', druclass = '', encclass = '', magclass = '', mnkclass = 'on', necclass = '', palclass = 'on', rngclass = '', rogclass = '', shdclass = 'on', shmclass = 'on', warclass = '', wizclass = '' WHERE id = ''Updated data successfully

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Your $id is no good; it shows as empty in this query. You are successfully updating no records (unless you have records that are an empty string). On the plus side it means your syntax is good.

    Why are so many of these entries empty? If you have empty/nullable datatypes in your structure, that (usually) indicates that the structure isn't normalized. You'll need to look into SQL injection as well; you can walk the post data through a stripslashes (if necessary) and a mysql_real_escape_string, or look at using prepared statements and binding them.

  • #5
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Item Name should never be empty. I'm not sure why there are so many empty datatypes. Could it be something in my update html form? Somehow it's not passing the id to the query?

  • #6
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Still haven't been able to get this to work and I know it has to be something stupid simple

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by Iggy0828 View Post
    Item Name should never be empty. I'm not sure why there are so many empty datatypes. Could it be something in my update html form? Somehow it's not passing the id to the query?
    Yep, that's likely exactly where the problem comes from. Post the HTML form in use (the entire form).

  • #8
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ok here's the html form

    PHP Code:
    <?php
        $var
    = @$_GET['id'];
        
    $trimmed trim($var);
        
    $limit=10;
        
        if (
    $trimmed == "") {
            echo
    "<p>Please enter a search...</p>";
            exit;
        }
        if (!isset(
    $var)) {
            echo 
    "<p>There is no search parameter...</p>";
            exit;
        }
        
    mysql_connect("localhost","username","password");
        
    mysql_select_db("ketocon_quila") or die("Unable to select database");
        
    $query "SELECT * FROM Items2 WHERE id LIKE \"%$trimmed%\" ORDER by id";
        
    $result mysql_query($query);
        echo 
    '<form action="edit_form.php" method="post">';
        echo 
    '<table border="2" width="5000" cellspacing="0" cellpadding="3">';
        echo 
    "<tr>";
        echo 
    '<th width="8">DBID</th>';
        echo 
    '<th width="12">SoD Item ID</th>';
        echo 
    '<th width="4">Tier</th>';
        echo 
    '<th width="255">ItemName</th>';
        echo 
    '<th width="4">AC</th>';
        echo 
    '<th width="4">STR</th>';
        echo 
    '<th width="4">STA</th>';
        echo 
    '<th width="4">DEX</th>';
        echo 
    '<th width="4">AGI</th>';
        echo 
    '<th width="4">CHA</th>';
        echo 
    '<th width="4">WIS</th>';
        echo 
    '<th width="4">INT</th>';
        echo 
    '<th width="4">HP</th>';
        echo 
    '<th width="4">Mana</th>';
        echo 
    '<th width="4">MR</th>';
        echo 
    '<th width="4">FR</th>';
        echo 
    '<th width="4">CR</th>';
        echo 
    '<th width="4">PR</th>';
        echo 
    '<th width="4">DR</th>';
        echo 
    '<th width="6">FT</th>';
        echo 
    '<th width="6">CrtStr</th>';
        echo 
    '<th width="6">MdShld</th>';
        echo 
    '<th width="6">StnRes</th>';
        echo 
    '<th width="6">DmgRed</th>';
        echo 
    '<th width="6">Aggr</th>';
        echo 
    '<th width="6">SplWrd</th>';
        echo 
    '<th width="12">Instrument</th>';
        echo 
    '<th width="6">InsMod</th>';
        echo 
    '<th width="12">BaneType</th>';
        echo 
    '<th width="6">BneDmg</th>';
        echo 
    '<th width="12">SkillMod</th>';
        echo 
    '<th width="6">ModAmt</th>';
        echo 
    '<th width="255">FocusEffect</th>';
        echo 
    '<th width="255">SpellEffect</th>';
        echo 
    '<th width="6">WpnDmg</th>';
        echo 
    '<th width="6">WpnDly</th>';
        echo 
    '<th width="6">WpnTyp</th>';
        echo 
    '<th width="6">Ear</th>';
        echo 
    '<th width="6">Neck</th>';
        echo 
    '<th width="6">Head</th>';
        echo 
    '<th width="6">Face</th>';
        echo 
    '<th width="6">Chest</th>';
        echo 
    '<th width="6">Back</th>';
        echo 
    '<th width="6">Arms</th>';
        echo 
    '<th width="6">Shldrs</th>';
        echo 
    '<th width="6">Wrist</th>';
        echo 
    '<th width="6">Waist</th>';
        echo 
    '<th width="6">Hands</th>';
        echo 
    '<th width="6">Fingers</th>';
        echo 
    '<th width="6">Legs</th>';
        echo 
    '<th width="6">Feet</th>';
        echo 
    '<th width="6">Primry</th>';
        echo 
    '<th width="6">Secdry</th>';
        echo 
    '<th width="6">Range</th>';
        echo 
    '<th width="6">Ammo</th>';
        echo 
    '<th width="6">Charm</th>';
        echo 
    '<th width="6">T2 Aug</th>';
        echo 
    '<th width="6">T3 Aug</th>';
        echo 
    '<th width="6">T5 Aug</th>';
        echo 
    '<th width="255">Mob</th>';
        echo 
    '<th width="4">BRD</th>';
        echo 
    '<th width="4">BST</th>';
        echo 
    '<th width="4">CLR</th>';
        echo 
    '<th width="4">DRU</th>';
        echo 
    '<th width="4">ENC</th>';
        echo 
    '<th width="4">MAG</th>';
        echo 
    '<th width="4">MNK</th>';
        echo 
    '<th width="4">NEC</th>';
        echo 
    '<th width="4">PAL</th>';
        echo 
    '<th width="4">RNG</th>';
        echo 
    '<th width="4">ROG</th>';
        echo 
    '<th width="4">SHD</th>';
        echo 
    '<th width="4">SHM</th>';
        echo 
    '<th width="4">WAR</th>';
        echo 
    '<th width="4">WIZ</th>';
        echo 
    "</tr>";
        
        while (
    $row=mysql_fetch_array($result)) {
    ?>
    <tr>
    <td><? echo $row['id']; ?></td>
    <td><input type="number" name="soditemid" size=6 value="<? echo $row['soditemid']; ?>" /></td>
    <td><input type="number" name="tier" size=4 value="<? echo $row['Tier']; ?>" /></td>
    <td><input type="text" name="itemname" size=80 value="<? echo $row['ItemName']; ?>" /></td>
    <td><input type="number" name="itemac" size=5 value="<? echo $row['AC']; ?>" /></td>
    <td><input type="number" name="itemstr" size=5 value="<? echo $row['STR']; ?>" /></td>
    <td><input type="number" name="itemsta" size=5 value="<? echo $row['STA']; ?>" /></td>
    <td><input type="number" name="itemdex" size=5 value="<? echo $row['DEX']; ?>" /></td>
    <td><input type="number" name="itemagi" size=5 value="<? echo $row['AGI']; ?>" /></td>
    <td><input type="number" name="itemcha" size=5 value="<? echo $row['CHA']; ?>" /></td>
    <td><input type="number" name="itemwis" size=5 value="<? echo $row['WIS']; ?>" /></td>
    <td><input type="number" name="itemint" size=5 value="<? echo $row['INT']; ?>" /></td>
    <td><input type="number" name="itemhp" size=5 value="<? echo $row['HP']; ?>" /></td>
    <td><input type="number" name="itemmana" size=5 value="<? echo $row['Mana']; ?>" /></td>
    <td><input type="number" name="itemmr" size=5 value="<? echo $row['MR']; ?>" /></td>
    <td><input type="number" name="itemfr" size=5 value="<? echo $row['FR']; ?>" /></td>
    <td><input type="number" name="itemcr" size=5 value="<? echo $row['CR']; ?>" /></td>
    <td><input type="number" name="itempr" size=5 value="<? echo $row['PR']; ?>" /></td>
    <td><input type="number" name="itemdr" size=5 value="<? echo $row['DR']; ?>" /></td>
    <td><input type="number" name="itemft" size=5 value="<? echo $row['FT']; ?>" /></td>    
    <td><input type="number" name="itemcs" size=5 value="<? echo $row['CS']; ?>" /></td>
    <td><input type="number" name="itemms" size=5 value="<? echo $row['MS']; ?>" /></td>
    <td><input type="number" name="itemsr" size=5 value="<? echo $row['SR']; ?>" /></td>
    <td><input type="number" name="itemdmgr" size=5 value="<? echo $row['DmgR']; ?>" /></td>
    <td><input type="number" name="itemaggr" size=5 value="<? echo $row['Aggr']; ?>" /></td>
    <td><input type="number" name="itemsw" size=5 value="<? echo $row['SpellWard']; ?>" /></td>
    <td><input type="text" name="instrument" size=15 value="<? echo $row['Instrument']; ?>" /></td>
    <td><input type="number" name="instrumentmod" size=5 value="<? echo $row['InstrumentMod']; ?>" /></td>
    <td><input type="text" name="banetype" size=15 value="<? echo $row['BaneType']; ?>" /></td>
    <td><input type="number" name="banedmg" size=5 value="<? echo $row['BaneDmg']; ?>" /></td>
    <td><input type="text" name="skillmod" size=15 value="<? echo $row['SkillMod']; ?>" /></td>
    <td><input type="number" name="skillmodamt" size=5 value="<? echo $row['SkillModAmt']; ?>" /></td>
    <td><input type="text" name="focuseffect" size=80 value="<? echo $row['FocusEffect']; ?>" /></td>
    <td><input type="text" name="spelleffect" size=80 value="<? echo $row['SpellEffect']; ?>" /></td>
    <td><input type="number" name="weapondmg" size=5 value="<? echo $row['WeaponDmg']; ?>" /></td>
    <td><input type="number" name="weapondly" size=5 value="<? echo $row['WeaponDly']; ?>" /></td>
    <td><input type="text" name="weapontype" size=15 value="<? echo $row['WeaponType']; ?>" /></td>
    <td><input type="checkbox" name="earslot" <? echo ($row['earslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="neckslot" <? echo ($row['neckslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="headslot" <? echo ($row['headslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="faceslot" <? echo ($row['faceslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="chestslot" <? echo ($row['chestslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="backslot" <? echo ($row['backslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="armslot" <? echo ($row['armslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="shoulderslot" <? echo ($row['shoulderslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="wristslot" <? echo ($row['wristslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="waistslot" <? echo ($row['waistslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="handslot" <? echo ($row['handslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="fingerslot" <? echo ($row['fingerslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="legslot" <? echo ($row['legslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="feetslot" <? echo ($row['feetslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="prislot" <? echo ($row['prislot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="secslot" <? echo ($row['secslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="rangeslot" <? echo ($row['rangeslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="ammoslot" <? echo ($row['ammoslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="charmslot" <? echo ($row['charmslot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="aug2slot" <? echo ($row['aug2slot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="aug3slot" <? echo ($row['aug3slot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="aug5slot" <? echo ($row['aug5slot'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="text" name="Mob" size=80 value="<? echo $row['mob']; ?>" /></td>
    <td><input type="checkbox" name="brdclass" <? echo ($row['brdclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="bstclass" <? echo ($row['bstclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="clrclass" <? echo ($row['clrclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="druclass" <? echo ($row['druclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="encclass" <? echo ($row['encclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="magclass" <? echo ($row['magclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="mnkclass" <? echo ($row['mnkclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="necclass" <? echo ($row['necclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="palclass" <? echo ($row['palclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="rngclass" <? echo ($row['rngclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="rogclass" <? echo ($row['rogclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="shdclass" <? echo ($row['shdclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="shmclass" <? echo ($row['shmclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="warclass" <? echo ($row['warclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input type="checkbox" name="wizclass" <? echo ($row['wizclass'] ? 'checked="checked"' ''); ?> /></td>
    <td><input name="update" type="submit" id=<? echo ($row['id']); ?> value="Update"</td>
    </tr>
    <?
    }
    ?>
    </form>
    </table>
    Last edited by Iggy0828; 09-25-2012 at 10:23 PM.

  • #9
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Sorry for the bad formatting. The checkboxes all show up as they should when I echo the query, nothing else does though.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    That is not HTML. That is PHP code that GENERATES HTML. Not the same thing.

    To show us the HTML, bring the page up in your browser, click on the VIEW menu of the browser, click on the SOURCE or PAGE SOURCE menu item. *NOW* you are looking at the HTML as the browser sees it. Copy/paste the HTML here.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    You know, that code can't possibly work if the HTML page every shows more than one row (more than one id).

    Clicking on ANY of the submit buttons (the value="Update" buttons) will submit *ALL* the data from *ALL* the rows, and PHP is not equipped to handle that.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    No, I didn't know that so I guess I should change LIKE to = so it only pulls up one record on search.

  • #13
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    [html]
    <form action="edit_form.php" method="post"><table border="2" width="5000" cellspacing="0" cellpadding="3"><tr><th width="8">DBID</th><th width="12">SoD Item ID</th><th width="4">Tier</th><th width="255">ItemName</th><th width="4">AC</th><th width="4">STR</th><th width="4">STA</th><th width="4">DEX</th><th width="4">AGI</th><th width="4">CHA</th><th width="4">WIS</th><th width="4">INT</th><th width="4">HP</th><th width="4">Mana</th><th width="4">MR</th><th width="4">FR</th><th width="4">CR</th><th width="4">PR</th><th width="4">DR</th><th width="6">FT</th><th width="6">CrtStr</th><th width="6">MdShld</th><th width="6">StnRes</th><th width="6">DmgRed</th><th width="6">Aggr</th><th width="6">SplWrd</th><th width="12">Instrument</th><th width="6">InsMod</th><th width="12">BaneType</th><th width="6">BneDmg</th><th width="12">SkillMod</th><th width="6">ModAmt</th><th width="255">FocusEffect</th><th width="255">SpellEffect</th><th width="6">WpnDmg</th><th width="6">WpnDly</th><th width="6">WpnTyp</th><th width="6">Ear</th><th width="6">Neck</th><th width="6">Head</th><th width="6">Face</th><th width="6">Chest</th><th width="6">Back</th><th width="6">Arms</th><th width="6">Shldrs</th><th width="6">Wrist</th><th width="6">Waist</th><th width="6">Hands</th><th width="6">Fingers</th><th width="6">Legs</th><th width="6">Feet</th><th width="6">Primry</th><th width="6">Secdry</th><th width="6">Range</th><th width="6">Ammo</th><th width="6">Charm</th><th width="6">T2 Aug</th><th width="6">T3 Aug</th><th width="6">T5 Aug</th><th width="255">Mob</th><th width="4">BRD</th><th width="4">BST</th><th width="4">CLR</th><th width="4">DRU</th><th width="4">ENC</th><th width="4">MAG</th><th width="4">MNK</th><th width="4">NEC</th><th width="4">PAL</th><th width="4">RNG</th><th width="4">ROG</th><th width="4">SHD</th><th width="4">SHM</th><th width="4">WAR</th><th width="4">WIZ</th></tr><tr>
    <td>2</td>
    <td><input type="number" name="soditemid" size=6 value="0" /></td>
    <td><input type="number" name="tier" size=4 value="13" /></td>
    <td><input type="text" name="itemname" size=80 value="A Celestial Star" /></td>
    <td><input type="number" name="itemac" size=5 value="0" /></td>
    <td><input type="number" name="itemstr" size=5 value="0" /></td>
    <td><input type="number" name="itemsta" size=5 value="22" /></td>
    <td><input type="number" name="itemdex" size=5 value="0" /></td>
    <td><input type="number" name="itemagi" size=5 value="0" /></td>
    <td><input type="number" name="itemcha" size=5 value="16" /></td>
    <td><input type="number" name="itemwis" size=5 value="12" /></td>
    <td><input type="number" name="itemint" size=5 value="12" /></td>
    <td><input type="number" name="itemhp" size=5 value="225" /></td>
    <td><input type="number" name="itemmana" size=5 value="240" /></td>
    <td><input type="number" name="itemmr" size=5 value="40" /></td>
    <td><input type="number" name="itemfr" size=5 value="0" /></td>
    <td><input type="number" name="itemcr" size=5 value="0" /></td>
    <td><input type="number" name="itempr" size=5 value="0" /></td>
    <td><input type="number" name="itemdr" size=5 value="0" /></td>
    <td><input type="number" name="itemft" size=5 value="1" /></td>
    <td><input type="number" name="itemcs" size=5 value="0" /></td>
    <td><input type="number" name="itemms" size=5 value="0" /></td>
    <td><input type="number" name="itemsr" size=5 value="0" /></td>
    <td><input type="number" name="itemdmgr" size=5 value="0" /></td>
    <td><input type="number" name="itemaggr" size=5 value="0" /></td>
    <td><input type="number" name="itemsw" size=5 value="1" /></td>
    <td><input type="text" name="instrument" size=15 value="None" /></td>
    <td><input type="number" name="instrumentmod" size=5 value="0" /></td>
    <td><input type="text" name="banetype" size=15 value="" /></td>
    <td><input type="number" name="banedmg" size=5 value="0" /></td>
    <td><input type="text" name="skillmod" size=15 value="Evocation" /></td>
    <td><input type="number" name="skillmodamt" size=5 value="2" /></td>
    <td><input type="text" name="focuseffect" size=80 value="Range Increment VIII" /></td>
    <td><input type="text" name="spelleffect" size=80 value="Celestialstorm (Clicky, 2.0) - Decreases Hit Points by 5000" /></td>
    <td><input type="number" name="weapondmg" size=5 value="0" /></td>
    <td><input type="number" name="weapondly" size=5 value="0" /></td>
    <td><input type="text" name="weapontype" size=15 value="" /></td>
    <td><input type="checkbox" name="earslot" checked="checked" /></td>
    <td><input type="checkbox" name="neckslot" /></td>
    <td><input type="checkbox" name="headslot" /></td>
    <td><input type="checkbox" name="faceslot" /></td>
    <td><input type="checkbox" name="chestslot" /></td>
    <td><input type="checkbox" name="backslot" /></td>
    <td><input type="checkbox" name="armslot" /></td>
    <td><input type="checkbox" name="shoulderslot" /></td>
    <td><input type="checkbox" name="wristslot" /></td>
    <td><input type="checkbox" name="waistslot" /></td>
    <td><input type="checkbox" name="handslot" /></td>
    <td><input type="checkbox" name="fingerslot" /></td>
    <td><input type="checkbox" name="legslot" /></td>
    <td><input type="checkbox" name="feetslot" /></td>
    <td><input type="checkbox" name="prislot" /></td>
    <td><input type="checkbox" name="secslot" /></td>
    <td><input type="checkbox" name="rangeslot" /></td>
    <td><input type="checkbox" name="ammoslot" /></td>
    <td><input type="checkbox" name="charmslot" /></td>
    <td><input type="checkbox" name="aug2slot" /></td>
    <td><input type="checkbox" name="aug3slot" /></td>
    <td><input type="checkbox" name="aug5slot" /></td>
    <td><input type="text" name="Mob" size=80 value="Taeshlin the Fallen Guardian" /></td>
    <td><input type="checkbox" name="brdclass" /></td>
    <td><input type="checkbox" name="bstclass" /></td>
    <td><input type="checkbox" name="clrclass" checked="checked" /></td>
    <td><input type="checkbox" name="druclass" checked="checked" /></td>
    <td><input type="checkbox" name="encclass" checked="checked" /></td>
    <td><input type="checkbox" name="magclass" checked="checked" /></td>
    <td><input type="checkbox" name="mnkclass" /></td>
    <td><input type="checkbox" name="necclass" checked="checked" /></td>
    <td><input type="checkbox" name="palclass" /></td>
    <td><input type="checkbox" name="rngclass" /></td>
    <td><input type="checkbox" name="rogclass" /></td>
    <td><input type="checkbox" name="shdclass" /></td>
    <td><input type="checkbox" name="shmclass" checked="checked" /></td>
    <td><input type="checkbox" name="warclass" /></td>
    <td><input type="checkbox" name="wizclass" checked="checked" /></td>
    <td><input name="update" type="submit" id=2 value="Update"</td>
    </tr>
    </form>
    </table>
    [/html]

    Here is the html code as requested.
    Last edited by Iggy0828; 09-26-2012 at 12:29 AM.

  • #14
    New Coder
    Join Date
    Sep 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    changing it to showing only one record made no difference.

  • #15
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    Quote Originally Posted by Iggy0828 View Post
    No, I didn't know that so I guess I should change LIKE to = so it only pulls up one record on search.
    Not necessarily.

    One thing you could do is put each *ROW* in its own <form>, so then the submit button would only submit the data on that one row.
    Code:
    <tr>
        <form method="post" action="...">
        ...
        <td><input type="submit" ... ></td>
        </form>
    </tr>

    Now, any input into other rows would simply be lost, so you have to decide if this is a viable alternative for you.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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