Two types of drop down menus, how do I make them post?

Discussion in 'PHP' started by Matt Ridge, Dec 27, 2011.

  1. #1
    Ok, either the turkey dinner from Christmas is either still in my system, or my brain was fried from the eggnog, but for some reason I can't remember how to make sure that the drop down menus actually post correctly...

    Any help would be appreciated.

    The first is accessing an SQL table, and then it will post to another table later on... what I forget, is how to show which fields are being queried when being told to post, in English the output... is it user_id and name? so when I post it to a database, it goes into the name field?

    Sorry to sound forgetful but this Christmas was one of those I'd rather forget, and I think I forgot more of what I needed to remember than what I want to forget.

    
     <?php
         
    require_once('connectvars.php');
         
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    $mysqli->select_db('comp');
    
    
    $result = $mysqli->query("SELECT * FROM comp"); 
    $i = 0;
    
    
    echo "<SELECT name='name'>\n";
    
    
    while($row = $result->fetch_assoc()) {
     if ($i == 3) echo '<option value="lines">-----</option>';
     
     echo "<option value='{$row['user_id']}'>{$row['name']}</option>\n";
     
     $i++;
    }
    
    
    echo "</select>\n";
    $result->close();
          ?>
    
    Code (markup):
    The other is a standard drop down menu, now this one is straight php... now is the posting value comp? I hate to ask, because my brain is so addled right now I really can't remember my own code...

    
    				echo'<div id="cof">';
    					echo '<span class="b">Class of Failure:&nbsp;&nbsp;</span><br />';
    					echo '<select name="comp">';
    					echo '<option value="none">----None----</option>';
    					echo '<option value="mat">Materials</option>';
    					echo '<option value="fab">Fabrication</option>';
    					echo '<option value="draw">Drawing</option>';
    					echo '<option value="ass">Assembly</option>';
    					echo '<option value="test">Testing</option>';
    					echo '<option value="elec">Electrical</option>';
    					echo '<option value="prog">Programming</option>';
    					echo '<option value="mac">Machining</option>';
    					echo '<option value="ins">Inspection</option>';
    					echo '<option value="purch">Purchasing</option>';
    					echo '<option value="admin">Administrator</option>';
    					echo '</select>';
    				echo '</div>';
    
    Code (markup):
    Sorry if I sound daft, but just amuse me for the time being. Thanks...
     
    Matt Ridge, Dec 27, 2011 IP