Jump to content

Newbie Needs help adding users to program feature


topvader

Recommended Posts

ok so i think the easiest thing for me to do is to explain my scenario in full first

i have created an admin panel, that governs certain program features, everytime i create a certain feature i then want to add users to that feature

So, my workflow goes as such:

1. Create-feature.php

1a) creates a row in the feature table

1b) creates an Enum("0","1") column in the user field with that feature name

2.)edit-feature.php (the problem step)

2a) print all the usernames in a table with a checkbox

2b) when updated all the users checked will change the ENUM Column from 0 to 1

 

The code for the edit-feature is:

<form name="form1" action="" method=""

//blah blah blah $feature = $_GET['featurename'];//
$ch = "unchecked";

$sql3 = mysql_query("
SELECT *
FROM user
") or die(mysql_error());
while($row = mysql_fetch_array($sql3)){
$un = $row['username'];	
$state = $row[$feature];
if ($state ==1){
$ch = "checked";
}

$usertable ='   <table width="100" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td><input type="hidden" name="username" id="username" value="'.$un.'"/>' .$un. ' </td>
      </tr>
      <tr>
        <td> <input type="checkbox" name="adduser[]" id="adduser" value="yes" '.$ch.' />
        <label for="adduser"></td>
      </tr>
      </table> ' ;
   echo $usertable;  
}
  ?>
  <input type="hidden" name="featurename" id="featurename" value="'.$feature.'"/>
</form>  

I have the following questions:

once i get this to post i know i need a foreach loop. but how will i tie it to my user table?

 

is there a much easier way of doing this?

please let me know

 

thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.