Drop down menu acting as advanced buttons

how would i make a dropdown menu act as heaps of buttons the code for the buttons is below. Also my dropdown menu will not side next to the go button can someone help me with this too. Very much appreciated.

[code]


<?php
error_reporting(0);
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Changed database name
$tbl_name="users";
mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db($db_name)or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER by user_id";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>

<center><style type='text/css'>
table {
    border-collapse: collapse;
    border-spacing: 0;
    border: 1px solid black;
    -moz-border-radius-bottomleft:0px;
    -webkit-border-bottom-left-radius:0px;
    border-bottom-left-radius:0px;
    -moz-border-radius-bottomright:0px;
    -webkit-border-bottom-right-radius:0px;
    border-bottom-right-radius:0px;
    -moz-border-radius-topright:0px;
    -webkit-border-top-right-radius:0px;
    border-top-right-radius:0px;
    -moz-border-radius-topleft:0px;
    -webkit-border-top-left-radius:0px;
    border-top-left-radius:0px;
    height:100%;
    margin:0px;padding:0px;
} tr:last-child td:last-child {
    -moz-border-radius-bottomright:0px;
    -webkit-border-bottom-right-radius:0px;
    border-bottom-right-radius:0px;
}
table tr:first-child td:first-child {
    -moz-border-radius-topleft:0px;
    -webkit-border-top-left-radius:0px;
    border-top-left-radius:0px;
}
table tr:first-child td:last-child {
    -moz-border-radius-topright:0px;
    -webkit-border-top-right-radius:0px;
    border-top-right-radius:0px;
} tr:last-child td:first-child{
    -moz-border-radius-bottomleft:0px;
    -webkit-border-bottom-left-radius:0px;
    border-bottom-left-radius:0px;
} tr:hover td{ background-color:#ffffff; }
 td{
    vertical-align:middle;
    background-color:#ffffff;
    border:1px solid #000000;
    border-width:0px 1px 1px 0px;
    text-align:left;
    padding:7px;
    font-size:10px;
    font-family:Arial;
    font-weight:normal;
    color:#000000;
} 
tr:last-child td{ border-width:0px 1px 0px 0px;} 
tr td:last-child{ border-width:0px 0px 1px 0px; } 
tr:last-child td:last-child{ border-width:0px 0px 0px 0px; }
 tr:first-child td{
    background:-o-linear-gradient(bottom, #ff7f00 5%, #ff0000 100%);
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ff7f00), color-stop(1, #ff0000) );
    background:-moz-linear-gradient( center top, #ff7f00 5%, #ff0000 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff7f00', endColorstr='#ff0000');  background: -o-linear-gradient(top,#ff7f00,ff0000);
    background-color:#ff7f00;
    border:0px solid #000000;
    text-align:center;
    border-width:0px 0px 1px 1px;
    font-size:14px;
    font-family:Arial;
    font-weight:bold;
    color:#ffffff;
}
 tr:first-child:hover td{
    background:-o-linear-gradient(bottom, #ff7f00 5%, #ff0000 100%);
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ff7f00), color-stop(1, #ff0000) );
    background:-moz-linear-gradient( center top, #ff7f00 5%, #ff0000 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff7f00', endColorstr='#ff0000');  background: -o-linear-gradient(top,#ff7f00,ff0000);
    background-color:#ff7f00;
}
 tr:first-child td:first-child{
    border-width:0px 0px 1px 0px;
}
 tr:first-child td:last-child{
    border-width:0px 0px 1px 1px;
}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$("#select-all").on("click", function() {
  var all = $(this);
  $('input:checkbox').each(function() {
       $(this).prop("checked", all.prop("checked"));
  });
});
});>  

function jumpTo() { 
var list = document.navList.subMenu 
if (list.options[list.selectedIndex].value != "Choose One") { 
location = list.options[list.selectedIndex].value 
</script>
<form name="form1" method="post" action="">
                <table align='center'>
                    <tr>
                       <td>
                       <input type="checkbox" id="select-all" name="selectAll" value=""/>
                        </td>
                        <td>
                            ID
                        </td>
                        <td >
                            Username
                        </td>
                        <td>
                            Email
                        </td>
                        <td>
                            Admin
                        </td>
                        <td>
                            User Active
                        </td>
                    </tr></center>

<?php while($rows=mysql_fetch_array($result, MYSQL_ASSOC))
  {
  if ($rows['user_perm_level'] == "2") 
{
$admin = 'Yes';
}
else {
$admin = 'No';
}

  if ($rows['user_active'] == "1") 
{
$active = 'Yes';
}
else {
$active = 'No';
} ?>

  <tr>
  <td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['user_id']; ?>"></td>
  <td><?php echo $rows['user_id']; ?></td>
  <td><?php echo $rows['user_name']; ?></td>
  <td><?php echo $rows['user_email']; ?></td>
  <td><?php echo $admin ?></td>
  <td><?php echo $active ?></td>
  </tr>
<?php  } ?>
</table>
Choose a theme Up Down
Submit function onChange(){ var value = $('#input').val(); $('#log').append('

New value: ' + value + '

'); }
function submit(){
    alert('value submitted');
}
</script>
<input name="delete" type="submit" id="delete" value="Delete Users">
<input name="newuser" type="submit" id="newuser" value="Add User">
<input name="user_perm_level_up" type="submit" id="user_perm_level_up" value="Upgrade">
<input name="user_perm_level_down" type="submit" id="user_perm_level_down" value="Downgrade">
<input name="activate_user_active" type="submit" id="activate_user_active" value="Activate">
<input name="deactivate_user_active" type="submit" id="deactivate_user_active" value="Deactivate">
</table>

<?php

if(isset($_POST['delete'])){
$checkbox = $_POST['checkbox'];
for($i=0;$i<count($_POST['checkbox']);$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE user_id='$del_id'";
$result = mysql_query($sql);}

if($result){echo "<meta http-equiv='refresh' content='0; url=' />";}}

?>

<?php

       if (isset($_POST["user_perm_level_up"]) AND !empty($_POST["user_perm_level_up"])) {
            $checkboxup = $_POST['checkbox'];
            for($i=0;$i<count($_POST['checkbox']);$i++){
            $up_id = $checkboxup[$i];
            $sql = "UPDATE $tbl_name SET user_perm_level = 2 WHERE user_id ='$up_id'";
            $result = mysql_query($sql);}

            if($result){echo "<meta http-equiv='refresh' content='0; url=' />";}}

 elseif (isset($_POST["user_perm_level_down"]) AND !empty($_POST["user_perm_level_down"])) {
            $checkboxdown = $_POST['checkbox'];
            for($i=0;$i<count($_POST['checkbox']);$i++){
            $down_id = $checkboxdown[$i];
            $sql = "UPDATE $tbl_name SET user_perm_level = 1 WHERE user_id ='$down_id'";
            $result = mysql_query($sql);}

            if($result){echo "<meta http-equiv='refresh' content='0; url=' />";}}

?>       
<?php
       if (isset($_POST["activate_user_active"]) AND !empty($_POST["activate_user_active"])) {
            $checkboxactivate = $_POST['checkbox'];
            for($i=0;$i<count($_POST['checkbox']);$i++){
            $activate_id = $checkboxactivate[$i];
            $sql = "UPDATE $tbl_name SET user_active = 1 WHERE user_id ='$activate_id'";
            $result = mysql_query($sql);}

            if($result){echo "<meta http-equiv='refresh' content='0; url=' />";}}

 elseif (isset($_POST["deactivate_user_active"]) AND !empty($_POST["deactivate_user_active"])) {
            $checkboxdeactivate = $_POST['checkbox'];
            for($i=0;$i<count($_POST['checkbox']);$i++){
            $deactivate_id = $checkboxdeactivate[$i];
            $sql = "UPDATE $tbl_name SET user_active = 0 WHERE user_id ='$deactivate_id'";
            $result = mysql_query($sql);}

            if($result){echo "<meta http-equiv='refresh' content='0; url=/' />";}}            

mysql_close();
?>
</form></div>[/code]

Thanks Joshua

Not sure exactly what your question is. First, a drop-down IS a heap of buttons. But, with only one value allowed in it. You select from a lot of different selections.

Normally, you have a VALUE for each selection and that value is not seen by the user.
The user will see the text and the VALUE of that selection would be seen by your code.
Normally, you have a DEFAULT value which would be set to a value of “NONE” or “0” or whatever
is your default value. You do not test for ISSET on a drop-down as it is already set to the first
item in the list or one that you select prior to display. You just test for the VALUE of the SELECT name.
If it is equal to “NONE” or ‘0’ then they did not set the drop-down.

Not really sure if that helps or not.

is the anything else i can use instead of buttons to do the job

Josh, well, tell us what you are trying to do. You showed a lot of code, but, what are you attempting to
do with it? You show Javascript/JQuery code, PHP code, form code, lots of CSS code and HTML code.
It is hard to tell what you are trying to do.

Drop-downs and menus are very easy to do and they do not need all of that code. So, perhaps if you
explain what you are trying to do, we can help. (I’m heading to bed now, though. It’s 2:15 AM here…)

Let us know and we can help…

im am making a admin page that can activate, deactivate, make admin and more just instead of selecting the users and then click one button of 10 i wanted to use dropdown menus to act as all the buttons

Well, if you mean you want a list of users and want to select various ones for options,
I think you want to use just a checkmark for each. Therefore, you use your database and pull
out the list of users. Display it in a simple table with check-boxes next to each user. Inside the
check-box fields, you use the user’s ID#. Then, when you process the PHP code, it can loop thru
all of the check-box values and see which ones are checked. Is that what you mean?

Normally, for activate/deactive, you would just have a table that would have those two buttons next
to each user. Inside the button’s field code, you would set the value to use the user’s ID# same as
a check-box. Once you press any button, that user would be activated or deactivated and the display
refreshed showing so. (But for checkboxes, it would loop thru the list.)

Still unclear on what you are trying to do. Do you have a page online that you could post so we could
see what your page looks like?

Not sure if this helped. Hope so…

define(“EMAIL_USE_SMTP”, true);
define(“EMAIL_SMTP_HOST”, “ssl://smtp.gmail.com”);
define(“EMAIL_SMTP_AUTH”, true);
define(“EMAIL_SMTP_USERNAME”, “”);
define(“EMAIL_SMTP_PASSWORD”, “”);
define(“EMAIL_SMTP_PORT”, 465);
define(“EMAIL_SMTP_ENCRYPTION”, “ssl”);
define(“EMAIL_PASSWORD_RESET_URL”, URL . “login/verifypasswordreset”);
define(“EMAIL_PASSWORD_RESET_FROM_EMAIL”, "[email protected]");
define(“EMAIL_PASSWORD_RESET_FROM_NAME”, “My Project”);
define(“EMAIL_PASSWORD_RESET_SUBJECT”, “Password reset for PROJECT XY”);
define(“EMAIL_PASSWORD_RESET_CONTENT”, "Please click on this link to reset your password: “);
define(“EMAIL_VERIFICATION_URL”, URL . “login/verify”);
define(“EMAIL_VERIFICATION_FROM_EMAIL”, "[email protected]”);
define(“EMAIL_VERIFICATION_FROM_NAME”, “My Project”);
define(“EMAIL_VERIFICATION_SUBJECT”, “Account activation for PROJECT XY”);
define(“EMAIL_VERIFICATION_CONTENT”, "Please click on this link to activate your account: ");

Can u see a mistake

Well, Josh, that is a LOT of define’s for variables, but, it has nothing to do with CODE!

So, this is your first question…

how would i make a dropdown menu act as heaps of buttons the code for the buttons is below. Also my dropdown menu will not side next to the go button can someone help me with this too. Very much appreciated.
Now, a dropdown is easy to handle! Any dropdown menu is easy to handle! What is a "heaps of buttons"???

So, we can help you if we know the question!

Your second question:

is the anything else i can use instead of buttons to do the job
What job?

Your last question:

im am making a admin page that can activate, deactivate, make admin and more just instead of selecting the users and then click one button of 10 i wanted to use dropdown menus to act as all the buttons
What does activate/deactive admin accounts mean? What does wanting to use dropdown menus as buttons mean?

We can solve ALL of your problems if we know what the questions mean. Showing DEFINE’s to us mean
nothing without the rest of the code as to what they pertain to. And, please please place any code into
PHP tags. Makes it quicker to copy to our test servers…

Sorry Josh, didn’t help in this post, but we are not clear on what you need help with!
Help us help you… Thanks!

I think what he wants to do is replace all those inputs with a drop down box, instead of having separate buttons for each task.

this group





Would become

[code]

Delete Users
Add User
Upgrader
<option value=‘user_perm_level_down’’>Downgrade
Activate
Deactivate

[/code]

The jquery would look something like

on.document(ready) { $("#permLevels").click(function() { $.post('userLevels.php', $("#permForm").serialize(), function(data) { $("#result_div").html(data.result); }); });

Richei,

I think you are correct. I went back to the first post and am guessing that is what he is asking, too!
Sometimes, I overlook the obvious when trying to help. And, usually that is at 2 AM like this one was.
Smiles!

So, Josh, is Richei’s solution what you needed?

How would I add a go button

Josh, Richei gave you the button in the second part of the code he posted.

Basically, you have two ways to do a “go” button which programmers call a submit button.
One way is to post the form to a PHP file and let it do the work. But, since you have commands in
your drop-down options, Richei set it up to use a JQuery call that handles your selection and then
posts the form. Either way works.

I also have another problem with my login system my password checker isn’t working :frowning:
I have attached the two files. Thanks Joshua


input.txt (1.26 KB)

login.txt (41.8 KB)

Well, that is really another topic, but, anyway…

In your login code, you test for the user-name using $_POST[‘user_name’] variable.
This means you are testing the posted value from the input form.

But, then, you access the database using a variable user-names not the posted value.
So, the user-name it looks for in the database is not valid.

Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service