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.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Display and hide of form edits

    Hi Guys,

    Please help! I have a permission field in mysql database, so if that field is 1 then show all fields, if it is 0 then show only a few fields.. Below is my coding... Does not work at all, only displays all the values


    private function getUserEditForm(AirtimeUser $user)//Edit form display
    {
    $permission == 1;
    //Coding added by Chris
    //Query the selects the permission number
    $cmd = "SELECT
    airtime_users.mod_user_permissions
    FROM airtime_users
    where airtime_users.mod_user_permissions = '$permission'";

    if(!$cmd)
    {
    $output = "<form name=\"main\" method=\"post\">";//Output is set as a POST function
    $output = $output . "<table width=100%>";//Create a table and display each texbox and value
    $output = $output . "<tr><td>User Id</td><td>" . $user->get_airtime_user_id () . "</td></tr>";
    $output = $output . "<tr><td>CDR Download permission</td><td><input type=text name=mod_download_cdr value=" . $user->get_mod_download_cdr () . "></td></tr>";
    $output = $output . "<tr><td>SIM Summary download permission</td><td><input type=text name=mod_download_sim_summary value=" . $user->get_mod_download_sim_summary () . "></td></tr>";
    $output = $output . "<tr><td>Username</td><td><input type=text name=username value=" . $user->get_username () . "></td></tr>";
    $output = $output . "<tr><td>Password</td><td><input type=password name=passwd value=" . $user->get_passwd () . "></td></tr>";
    $output = $output . "<tr><td colspan=2><a href=\"javascript:saveUser(" . $user->get_airtime_user_id () . ");\">Save User</a>";
    $output = $output . "</td></tr>";
    $output = $output . "</table></form>";
    $result = $this->execCommand($cmd);
    }
    else
    {
    $output = "<form name=\"main\" method=\"post\">";//Output is set as a POST function
    $output = $output . "<table width=100%>";//Create a table and display each texbox and value
    $output = $output . "<tr><td>User Id</td><td>" . $user->get_airtime_user_id () . "</td></tr>";
    $output = $output . "<tr><td>CDR Download permission</td><td><input type=text name=mod_download_cdr value=" . $user->get_mod_download_cdr () . "></td></tr>";
    $output = $output . "<tr><td>SIM Summary download permission</td><td><input type=text name=mod_download_sim_summary value=" . $user->get_mod_download_sim_summary () . "></td></tr>";
    $output = $output . "<tr><td>Allow user management</td><td><input type=text name=mod_user_add value=" . $user->get_mod_user_add () . "></td></tr>";
    $output = $output . "<tr><td>Allow permission management</td><td><input type=text name=mod_user_permissions value=" . $user->get_mod_user_permissions () . "></td></tr>";
    $output = $output . "<tr><td>Allow access to custom reports</td><td><input type=text name=mod_custom_reports value=" . $user->get_mod_custom_reports () . "></td></tr>";
    $output = $output . "<tr><td>Allow access to interactive reports</td><td><input type=text name=mod_interactive_report value=" . $user->get_mod_interactive_report () . "></td></tr>";
    $output = $output . "<tr><td>Username</td><td><input type=text name=username value=" . $user->get_username () . "></td></tr>";
    $output = $output . "<tr><td>Password</td><td><input type=password name=passwd value=" . $user->get_passwd () . "></td></tr>";
    $output = $output . "<tr><td>Parent User</td><td><input type=text name=parent_user_id value=" . $user->get_parent_user_id() . "></td></tr>";
    $output = $output . "<tr><td colspan=2><a href=\"javascript:saveUser(" . $user->get_airtime_user_id () . ");\">Save User</a>";

    if(!$user->isNewUser())//If not new user, only for edit
    {
    $output = $output . " :: <a href=\"javascript:setSimPermissions(" . $user->get_airtime_user_id () . ");\">Modify SIM permissions</a>";
    $output = $output . " :: <a href=\"javascript:setReportPermissions(" . $user->get_airtime_user_id () . ");\">Modify Report permissions</a>";
    }

    $output = $output . "</td></tr>";
    $output = $output . "</table></form>";
    }

    return $output;
    }

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    $permission == 1;
    That's the comparison operator and not the assignment operator.
    if(!$cmd)
    That's meaningless as $cmd contains just a string (query). Don't you need to execute it by mysql_query() function ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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