...

View Full Version : Display and hide of form edits



chrisiboy
10-08-2012, 10:04 AM
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;
}

abduraooft
10-08-2012, 03:39 PM
$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 ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum