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 22
  1. #1
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Question Need help with php form submit

    Hey, I have this form i have been working on. Its a checkbox table to update admin rights. I need to it submit a 1 or 0 into the database depending on if its checked or not. I think im close, but i cant get the 1 or 0 to update. Can anyone help ?

    PHP Code:
        <fieldset width='95%'>
        <legend><b>Menus</b></legend>
        
        <table width='100%' bgcolor='#F1F1F1'>
        <form name='give_menu_rights' method='post' action=''>
        <tr>
        <td width='150' height='25' style='text-align:center; font-weight:bold; background:#CCC;'>
        Title
        </td>
        <?
        
                $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                while(
    $stafflist mysql_fetch_array($staff))
                {
                
    ?>
                    <td width='25' style='text-align:center; font-weight:bold; background:#CCC;' title='<?echo $stafflist[name];?>'><?echo $stafflist[abv];?></td>
                <?
                
    }
                
    ?>
        </tr>

        

    <?
                $menu 
    mysql_query("SELECT * FROM cp_rights ORDER BY id ASC");
                while(
    $menulist mysql_fetch_array($menu))
                {
                
    ?>
                    <input type='hidden' name='id[<?echo $menulist[id];?>]' value='<?echo $menulist[id];?>'>
                        <tr>
                            <td style='background:#d4d4d4;'>&nbsp;&nbsp;<a href='admin.php?action=editSubMenu&menu[id]=<?echo $menulist[id];?>'><?echo $menulist[name];?></a></td>
                            <?
                                $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                                while(
    $stafflist mysql_fetch_array($staff))
                                {
                                
    ?>
                                    <td style='background:#d4d4d4; text-align:center;'><input type='checkbox' name='<?echo''.$stafflist[name].''.$menulist[id].''?>' title='<?echo $stafflist[name];?> | <?echo $menulist[name];?>' /></td>
                                    
                                    
                                <?
                                        $field 
    ''.$stafflist[name].''.$menulist[id].'';
                                        
    $subcheck = (isset($_POST['$stafflist[name];$menulist[id];'])) ? 0;
                                                                                    if(!empty(
    $_POST['AddMenuRights']))
                                                                                    
                                                                                    
            {
            


    echo 
    $field$subcheck;
            
            
    mysql_query("UPDATE cp_rights SET gm='$subcheck', owner='$subcheck' WHERE id='$menulist[id]'");
        
            
            }

                                }
                                
    ?>
                        </tr>
                <?
                
    }
                

                
    ?>

        

        <tr>
        <td colspan='25'>
        <input type='submit' name='AddMenuRights' value='Update Position Rights'>
        </td>
        </tr>
            </form>
        </table>
        
        </fieldset>

  • #2
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Can anyone help.till cant seem to get this to work ?

  • #3
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Still cant get this to work lol

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Blimey, not sure how your thread has been ignored for so long.. one of us normally picks up on a 0 reply thread...

    This line:
    mysql_query("UPDATE cp_rights SET gm='$subcheck', owner='$subcheck' WHERE id='$menulist[id]'");

    Can you change it to:
    PHP Code:
    $Query "UPDATE cp_rights SET gm='$subcheck', owner='$subcheck' WHERE id='$menulist[id]'";

    print 
    $Query;

    if (!
    mysql_query($Query))
       {
       print 
    mysql_error();
       } 
    Print the query so we can see what it looks like with the variables in it so we can be sure they're all there. Additionally if the query fails you'll get an error message.

    Report back with both the printed sql statement and any error message.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #5
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    Blimey, not sure how your thread has been ignored for so long.. one of us normally picks up on a 0 reply thread...

    This line:
    mysql_query("UPDATE cp_rights SET gm='$subcheck', owner='$subcheck' WHERE id='$menulist[id]'");

    Can you change it to:
    PHP Code:
    $Query "UPDATE cp_rights SET gm='$subcheck', owner='$subcheck' WHERE id='$menulist[id]'";

    print 
    $Query;

    if (!
    mysql_query($Query))
       {
       print 
    mysql_error();
       } 
    Print the query so we can see what it looks like with the variables in it so we can be sure they're all there. Additionally if the query fails you'll get an error message.

    Report back with both the printed sql statement and any error message.
    Well i went off this project for a while because i could'nt get this to work, said i would try again.

    I updated the code and didnt get any error but it still dosent work.

    Here is what i have now, it could be even more messed up then before because ive tried 150 dif things lol


    EDIT: Here is the qry: UPDATE cp_rights SET gm='0', owner='0' WHERE id='1' UPDATE cp_rights SET gm='0', owner='0' WHERE id='1'

    PHP Code:
        <fieldset width='95%'>
        <legend><b>Menus</b></legend>
        
        <table width='100%' bgcolor='#F1F1F1'>
        <form name='give_menu_rights' method='post' action=''>
        <tr>
        <td width='150' height='25' style='text-align:center; font-weight:bold; background:#CCC;'>
        Title
        </td>
        <?
        
                $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                while(
    $stafflist mysql_fetch_array($staff))
                {
                
    ?>
                    <td width='25' style='text-align:center; font-weight:bold; background:#CCC;' title='<?echo $stafflist[name];?>'><?echo $stafflist[abv];?></td>
                <?
                
    }
                
    ?>
        </tr>

        

    <?
                $menu 
    mysql_query("SELECT * FROM cp_rights ORDER BY id ASC");
                while(
    $menulist mysql_fetch_array($menu))
                {
                
    ?>
                    <input type='hidden' name='id[<?echo $menulist[id];?>]' value='<?echo $menulist[id];?>'>
                        <tr>
                            <td style='background:#d4d4d4;'>&nbsp;&nbsp;<a href='admin.php?action=editSubMenu&menu[id]=<?echo $menulist[id];?>'><?echo $menulist[name];?></a></td>
                            <?
                                $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                                while(
    $stafflist mysql_fetch_array($staff))
                                {
                                
    ?>
                                    <td style='background:#d4d4d4; text-align:center;'><input type='checkbox' name='<?echo''.$stafflist[name].''.$menulist[id].''?>' title='<?echo $stafflist[name];?> | <?echo $menulist[name];?>' /></td>
                                    
                                    
                                <?
                                        $field 
    ''.$stafflist[name].''.$menulist[id].'';
                                        
    $subcheck = (isset($_POST['$stafflist[name];$menulist[id];'])) ? 0;
                                                                                    if(!empty(
    $_POST['AddMenuRights']))
                                                                                    
                                                                                    
            {
            


    echo 
    $field$subcheck;
            
            
    $Query "UPDATE cp_rights SET gm='$subcheck', owner='$subcheck' WHERE id='$menulist[id]'";

    print 
    $Query;

    if (!
    mysql_query($Query))
       {
       print 
    mysql_error();
       } 
        
            
            }

                                }
                                
    ?>
                        </tr>
                <?
                
    }
                

                
    ?>

        

        <tr>
        <td colspan='25'>
        <input type='submit' name='AddMenuRights' value='Update Position Rights'>
        </td>
        </tr>
            </form>
        </table>
        
        </fieldset>
        <?
    Last edited by DjDanHayden; 05-30-2013 at 11:59 AM.

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by tangoforce View Post
    Report back with both the printed sql statement and any error message.
    Quote Originally Posted by DjDanHayden View Post
    I updated the code and didnt get any error but it still dosent work.
    I can't help you unless you help me

    Please come back with the SQL statement that is printed in the html. You can also try running that sql through the sql tab in phpmyadmin (be sure to select your database first)
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #7
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    I can't help you unless you help me

    Please come back with the SQL statement that is printed in the html. You can also try running that sql through the sql tab in phpmyadmin (be sure to select your database first)
    Sorry i edited my post with the qry, i got mixed up because i already had one printing.


    EDIT: Here is the qry: UPDATE cp_rights SET gm='0', owner='0' WHERE id='1' UPDATE cp_rights SET gm='0', owner='0' WHERE id='1'
    Last edited by DjDanHayden; 05-30-2013 at 12:19 PM.

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    What happens when you run that query manually in phpmyadmin?

    If you don't know..:








    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #9
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    0 rows affected. ( Query took 0.1847 sec )

    UPDATE cp_rights SET gm = '0',
    owner = '0' WHERE id = '1'

    The database is fine its just the code i think.

    EDIT: When i move the qry inside the menu loop and only tick the gm box, i get:

    UPDATE cp_rights SET gm='1', owner='1' WHERE id='1' UPDATE cp_rights SET gm='0', owner='0' WHERE id='1'

    So it loops twice, so when i add exit; at the end and only tick the gm box i get:

    UPDATE cp_rights SET gm='1', owner='1' WHERE id='1'


    EDIT EDIT: I think the whole code is trash, can anyone show me how to do this ?? pleaseeeeeeee
    Last edited by DjDanHayden; 05-30-2013 at 12:36 PM.

  • #10
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by DjDanHayden View Post
    EDIT EDIT: I think the whole code is trash, can anyone show me how to do this ?? pleaseeeeeeee
    Don't throw your toys out of the pram! I've been helping someone else remotely using teamviewer to fix their bug and thus not been able to get back to you until now.

    As for showing you how its done, I'm trying to work out whats wrong first. You have to let us give you little tests to perform on your code to get to the bottom of it. Once we've worked out whats wrong, we can help you put it right but it does take time

    Also note that your code is badly formatted. The opening and closing braces { and } are all over the place so it makes it a lot harder to understand your code but I am working on it..
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #11
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by DjDanHayden View Post
    EDIT: When i move the qry inside the menu loop and only tick the gm box, i get:

    UPDATE cp_rights SET gm='1', owner='1' WHERE id='1' UPDATE cp_rights SET gm='0', owner='0' WHERE id='1'

    So it loops twice
    Right I've got your code in notepad++ and tidied it up so I can read it..

    Yes you will see two queries being printed. Thats because the print of the query is being done in a loop with nothing else being output between them so it will look like there are two queries in that one string but there is not.

    Quote Originally Posted by DjDanHayden View Post
    The database is fine its just the code i think.
    Does the query actually change anything? - What I mean is the fields that it is updating, are they already a different value or are they the same as in the query? - If they're the same then mysql won't update them and will return 0 rows affected.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #12
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    Right I've got your code in notepad++ and tidied it up so I can read it..

    Yes you will see two queries being printed. Thats because the print of the query is being done in a loop with nothing else being output between them so it will look like there are two queries in that one string but there is not.



    Does the query actually change anything? - What I mean is the fields that it is updating, are they already a different value or are they the same as in the query? - If they're the same then mysql won't update them and will return 0 rows affected.
    No it dosent, the code is just outputting the value 0.

  • #13
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Finally got it working

    Here is the working code.

    The last thing i need is how to have the checkbox checked if the value is 1 in the database ?

    PHP Code:
        <fieldset width='95%'>
        <legend><b>Menus</b></legend>   
        <table width='100%' bgcolor='#F1F1F1'>
            <form name='give_menu_rights' method='post' action=''>
                <tr>
                    <td width='150' height='25' style='text-align:center; font-weight:bold; background:#CCC;'>
                        Title
                    </td>
                    <?
                       $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                    while(
    $stafflist mysql_fetch_array($staff))
                    {
                    
    ?>
                        <td width='25' style='text-align:center; font-weight:bold; background:#CCC;' title='<?echo $stafflist[name];?>'><?echo $stafflist[abv];?></td>
                    <?
                    
    }
                    
    ?>
                </tr>
                <?
                $menu 
    mysql_query("SELECT * FROM cp_rights ORDER BY id ASC");
                while(
    $menulist mysql_fetch_array($menu))
                {
                    
    ?>
                    <input type='hidden' name='id[<?echo $menulist[id];?>]' value='<?echo $menulist[id];?>'>
                    <tr>
                        <td style='background:#d4d4d4;'>&nbsp;&nbsp;<a href='admin.php?action=editSubMenu&menu[id]=<?echo $menulist[id];?>'><?echo $menulist[name];?></a></td>
                        <?
                        $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                        while(
    $stafflist mysql_fetch_array($staff))
                        {
                            
    ?>
                            <td style='background:#d4d4d4; text-align:center;'><input type='checkbox' name='<?echo''.$stafflist[abv].''.$menulist[id].''?>' title='<?echo $stafflist[abv];?> | <?echo $menulist[name];?>'/></td>
                            <?
                                           
                            
    if(!empty($_POST['AddMenuRights']))
                            {
                                
    $subcheck = (isset($_POST[''.$stafflist[abv].''.$menulist[id].''])) ? 0;
                                
    $Query "UPDATE cp_rights SET ".$stafflist[abv]."='$subcheck' WHERE id='$menulist[id]'";
                            }
                        }
                        
    ?>
                    </tr>
                    <?
                
    }
                
    ?>
                <tr>
                    <td colspan='25'>
                        <input type='submit' name='AddMenuRights' value='Update Position Rights'>
                    </td>
                </tr>
            </form>
        </table>
        </fieldset>

  • #14
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    <input type="checkbox" name="whatever" value="something" checked>

    That will make the box checked.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    DjDanHayden (05-31-2013)

  • #15
    New Coder DjDanHayden's Avatar
    Join Date
    Nov 2008
    Location
    Ireland
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Ok well i added the extra menus i need to finish of this admin rights tables and guess what, now its broke... again...

    I got the checkbox stay checked working again with this:

    PHP Code:
    <? if($menulist[$poz] == '1'){echo'checked';}?>
    So thats not a problem. The problem is the query dosent update the databse when i check the boxs, so i echoed the query to get this:

    This cant be right ?? The values that are already set to 1 are the ones i had to set myself in the databse, when i try do it via the checkboxs it dosent update ?

    PHP Code:
    UPDATE cp_rights SET owner='1' WHERE id='1' UPDATE cp_rights SET GM='1' WHERE id='1' UPDATE cp_rights SET OM='0' WHERE id='1' UPDATE cp_rights SET SA='0' WHERE id='1' UPDATE cp_rights SET PA='0' WHERE id='1' UPDATE cp_rights SET HFS='0' WHERE id='1' UPDATE cp_rights SET FS='0' WHERE id='1' UPDATE cp_rights SET HHR='0' WHERE id='1' UPDATE cp_rights SET HR='0' WHERE id='1' UPDATE cp_rights SET HA='0' WHERE id='1' UPDATE cp_rights SET owner='1' WHERE id='2' UPDATE cp_rights SET GM='1' WHERE id='2' UPDATE cp_rights SET OM='0' WHERE id='2' UPDATE cp_rights SET SA='0' WHERE id='2' UPDATE cp_rights SET PA='0' WHERE id='2' UPDATE cp_rights SET HFS='0' WHERE id='2' UPDATE cp_rights SET FS='0' WHERE id='2' UPDATE cp_rights SET HHR='0' WHERE id='2' UPDATE cp_rights SET HR='0' WHERE id='2' UPDATE cp_rights SET HA='0' WHERE id='2' UPDATE cp_rights SET owner='1' WHERE id='3' UPDATE cp_rights SET GM='1' WHERE id='3' UPDATE cp_rights SET OM='0' WHERE id='3' UPDATE cp_rights SET SA='0' WHERE id='3' UPDATE cp_rights SET PA='0' WHERE id='3' UPDATE cp_rights SET HFS='0' WHERE id='3' UPDATE cp_rights SET FS='0' WHERE id='3' UPDATE cp_rights SET HHR='0' WHERE id='3' UPDATE cp_rights SET HR='0' WHERE id='3' UPDATE cp_rights SET HA='0' WHERE id='3' UPDATE cp_rights SET owner='1' WHERE id='4' UPDATE cp_rights SET GM='1' WHERE id='4' UPDATE cp_rights SET OM='0' WHERE id='4' UPDATE cp_rights SET SA='0' WHERE id='4' UPDATE cp_rights SET PA='0' WHERE id='4' UPDATE cp_rights SET HFS='0' WHERE id='4' UPDATE cp_rights SET FS='0' WHERE id='4' UPDATE cp_rights SET HHR='0' WHERE id='4' UPDATE cp_rights SET HR='0' WHERE id='4' UPDATE cp_rights SET HA='0' WHERE id='4' UPDATE cp_rights SET owner='1' WHERE id='5' UPDATE cp_rights SET GM='1' WHERE id='5' UPDATE cp_rights SET OM='0' WHERE id='5' UPDATE cp_rights SET SA='0' WHERE id='5' UPDATE cp_rights SET PA='0' WHERE id='5' UPDATE cp_rights SET HFS='0' WHERE id='5' UPDATE cp_rights SET FS='0' WHERE id='5' UPDATE cp_rights SET HHR='0' WHERE id='5' UPDATE cp_rights SET HR='0' WHERE id='5' UPDATE cp_rights SET HA='0' WHERE id='5' UPDATE cp_rights SET owner='1' WHERE id='6' UPDATE cp_rights SET GM='1' WHERE id='6' UPDATE cp_rights SET OM='0' WHERE id='6' UPDATE cp_rights SET SA='0' WHERE id='6' UPDATE cp_rights SET PA='0' WHERE id='6' UPDATE cp_rights SET HFS='0' WHERE id='6' UPDATE cp_rights SET FS='0' WHERE id='6' UPDATE cp_rights SET HHR='0' WHERE id='6' UPDATE cp_rights SET HR='0' WHERE id='6' UPDATE cp_rights SET HA='0' WHERE id='6' UPDATE cp_rights SET owner='0' WHERE id='7' UPDATE cp_rights SET GM='1' WHERE id='7' UPDATE cp_rights SET OM='0' WHERE id='7' UPDATE cp_rights SET SA='0' WHERE id='7' UPDATE cp_rights SET PA='0' WHERE id='7' UPDATE cp_rights SET HFS='0' WHERE id='7' UPDATE cp_rights SET FS='0' WHERE id='7' UPDATE cp_rights SET HHR='0' WHERE id='7' UPDATE cp_rights SET HR='0' WHERE id='7' UPDATE cp_rights SET HA='0' WHERE id='7' UPDATE cp_rights SET owner='0' WHERE id='8' UPDATE cp_rights SET GM='1' WHERE id='8' UPDATE cp_rights SET OM='0' WHERE id='8' UPDATE cp_rights SET SA='0' WHERE id='8' UPDATE cp_rights SET PA='0' WHERE id='8' UPDATE cp_rights SET HFS='0' WHERE id='8' UPDATE cp_rights SET FS='0' WHERE id='8' UPDATE cp_rights SET HHR='0' WHERE id='8' UPDATE cp_rights SET HR='0' WHERE id='8' UPDATE cp_rights SET HA='0' WHERE id='8' UPDATE cp_rights SET owner='0' WHERE id='9' UPDATE cp_rights SET GM='1' WHERE id='9' UPDATE cp_rights SET OM='0' WHERE id='9' UPDATE cp_rights SET SA='0' WHERE id='9' UPDATE cp_rights SET PA='0' WHERE id='9' UPDATE cp_rights SET HFS='0' WHERE id='9' UPDATE cp_rights SET FS='0' WHERE id='9' UPDATE cp_rights SET HHR='0' WHERE id='9' UPDATE cp_rights SET HR='0' WHERE id='9' UPDATE cp_rights SET HA='0' WHERE id='9' UPDATE cp_rights SET owner='0' WHERE id='10' UPDATE cp_rights SET GM='1' WHERE id='10' UPDATE cp_rights SET OM='0' WHERE id='10' UPDATE cp_rights SET SA='0' WHERE id='10' UPDATE cp_rights SET PA='0' WHERE id='10' UPDATE cp_rights SET HFS='0' WHERE id='10' UPDATE cp_rights SET FS='0' WHERE id='10' UPDATE cp_rights SET HHR='0' WHERE id='10' UPDATE cp_rights SET HR='0' WHERE id='10' UPDATE cp_rights SET HA='0' WHERE id='10' UPDATE cp_rights SET owner='0' WHERE id='11' UPDATE cp_rights SET GM='1' WHERE id='11' UPDATE cp_rights SET OM='0' WHERE id='11' UPDATE cp_rights SET SA='0' WHERE id='11' UPDATE cp_rights SET PA='0' WHERE id='11' UPDATE cp_rights SET HFS='0' WHERE id='11' UPDATE cp_rights SET FS='0' WHERE id='11' UPDATE cp_rights SET HHR='0' WHERE id='11' UPDATE cp_rights SET HR='0' WHERE id='11' UPDATE cp_rights SET HA='0' WHERE id='11' 

    Here is the current code:

    PHP Code:
        <fieldset width='95%'>
        <legend><b>Menus</b></legend>   
        <table width='100%' bgcolor='#F1F1F1'>
            <form name='give_menu_rights' method='post' action=''>
                <tr>
                    <td width='90' height='25' style='text-align:center; font-weight:bold; background:#CCC;'>
                        Title
                    </td>
                    <?
                       $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                    while(
    $stafflist mysql_fetch_array($staff))
                    {
                    
    ?>
                        <td width='25' style='text-align:center; font-weight:bold; background:#CCC;' title='<?echo $stafflist[name];?>'><?echo $stafflist[abv];?></td>
                    <?
                    
    }
                    
    ?>
                </tr>
                <?
                $menu 
    mysql_query("SELECT * FROM cp_rights ORDER BY id ASC");
                while(
    $menulist mysql_fetch_array($menu))
                {
                    
    ?>
                    <input type='hidden' name='id[<?echo $menulist[id];?>]' value='<?echo $menulist[id];?>'>
                    <tr>
                        <td style='background:#d4d4d4;'>&nbsp;&nbsp;>> <?echo $menulist[name];?></td>
                        <?
                        $staff 
    mysql_query("SELECT * FROM staff_positions ORDER BY id ASC");
                        while(
    $stafflist mysql_fetch_array($staff))
                        {
                        
                          
    $poz $stafflist['abv'];
                            
    ?>
                            <td style='background:#d4d4d4; text-align:center;'><input type='checkbox' name='<?echo''.$stafflist[abv].''.$menulist[id].''?>' title='<?echo $stafflist[abv];?> | <?echo $menulist[name];?><? if($menulist[$poz] == '1'){echo'checked';}?>/></td>
                            <?
                            
                    
                                           
                            
    if(!empty($_POST['AddMenuRights']))
                            {
                                
    $subcheck = (isset($_POST[''.$stafflist[abv].''.$menulist[id].''])) ? 0;
                                
    $Query "UPDATE cp_rights SET ".$stafflist[abv]."='$subcheck' WHERE id='$menulist[id]'";
                                
                                echo 
    $Query;
                            }
                        }
                        
    ?>
                    </tr>
                    <?
                
    }
                
    ?>
                <tr>
                    <td colspan='25'>
                        <input type='submit' name='AddMenuRights' value='Update Position Rights'>
                    </td>
                </tr>
            </form>
        </table>
        </fieldset>

    and here is the databse:

    PHP Code:
    --
    -- 
    Table structure for table `staff_positions`
    --

    CREATE TABLE IF NOT EXISTS `staff_positions` (
      `
    idint(11NOT NULL AUTO_INCREMENT,
      `
    nametext NOT NULL,
      `
    abvtext NOT NULL,
      `
    rightsint(11NOT NULL,
      `
    colortext NOT NULL,
      `
    ultext NOT NULL,
      `
    litext NOT NULL,
      
    PRIMARY KEY (`id`)
    ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

    --
    -- 
    Dumping data for table `staff_positions`
    --

    INSERT INTO `staff_positions` (`id`, `name`, `abv`, `rights`, `color`, `ul`, `li`) VALUES
    (1'Owner''owner'0'#FF0000'''''),
    (
    2'General Manager''GM'0'#FF0000'''''),
    (
    3'Operations Manager''OM'0''''''),
    (
    4'Site Administrator''SA'0''''''),
    (
    5'Platform Administrator''PA'0''''''),
    (
    6'Head of Fraud Squad''HFS'0''''''),
    (
    7'Fraud Squad''FS'0''''''),
    (
    8'Head of Human Resources''HHR'0''''''),
    (
    9'Human Resources''HR'0''''''),
    (
    10'Head Admin''HA'0''''''); 


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

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