Jump to content

[SOLVED] Sorry, but this code is driving me nuts! Can some one please help?


karatekid36

Recommended Posts

The problem is that I need the second pull down menu to be the same as the first.  When I view this file online in the browser, the second pull down menu does not pull the information from the table like it should.  I am sorry but I am still really new to php and mysql and I am trying to learn.  If someone could help me that would be great.  Thank you in advance.

 

<?php 
require_once ('mysql_connect.php'); // Connect to the db.

$page_title = 'Enter a New E-Board';
     include ('includes/header.html');
?>

<h2>Add an Executive Board </h2>
<form action="enter_eboard.php" method="post">

  <p>Starting Semester: 
    <label>
  <input type="radio" name="eboard_start" value="Fall" />
Fall</label>
    <label>
  <input type="radio" name="eboard_start" value="Spring" />
Spring</label>

    <?php
  // Make the years pull-down menu.
echo '<select name="start_year">';
$year = 2005;
while ($year <= 2020) {
echo "<option value=\"$year\">$year</option>\n";
$year++;
}
echo '</select>';
?>
</p>  
  
  
  <p>Ending  Semester:
    <label>
    <input type="radio" name="eboard_end" value="Fall" />
Fall</label>
    <label>
    <input type="radio" name="eboard_end" value="Spring" />
Spring</label>
    <?php
  // Make the years pull-down menu.
echo '<select name="end_year">';
$year = 2005;
while ($year <= 2020) {
echo "<option value=\"$year\">$year</option>\n";
$year++;
}
echo '</select>';
?>
</p>

<p><b>Master</b>
  <select name="master" ><option>No Brother</option>
  
  <?php

  $query = "SELECT user_id, CONCAT_WS(' ', first_name, last_name) AS name FROM brothers ORDER BY last_name, first_name ASC";
  if ($result = mysql_query($query)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "<option value=\"{$row['user_id']}\">{$row['name']}</option>\n";
      }
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />$query<br />". mysql_error();
  }

mysql_close($dbc);

?>

</select></p>

<p><strong>Lieutenant Master </strong>
  <select name="lt" ><option>No Brother</option>
  
  <?php

  $query2 = "SELECT user_id, CONCAT_WS(' ', first_name, last_name) AS name2 FROM brothers ORDER BY last_name, first_name ASC";
  if ($result2 = mysql_query($query2)) {
    if (mysql_num_rows($result2)) {
      while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) {
        echo "<option value=\"{$row['user_id']}\">{$row['name2']}</option>\n";
      }
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />$query2<br />". mysql_error();
  }

mysql_close($dbc);

?>
  </select></p>

<p><input type="submit" name="submit" value="Add E-Board" /></p>
<input type="hidden" name="submitted" value="TRUE" />	
  
</form>	

<?php
include ('./includes/footer.html');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.