karatekid36 Posted May 6, 2007 Share Posted May 6, 2007 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'); ?> Link to comment https://forums.phpfreaks.com/topic/50191-solved-sorry-but-this-code-is-driving-me-nuts-can-some-one-please-help/ Share on other sites More sharing options...
benjaminbeazy Posted May 6, 2007 Share Posted May 6, 2007 you closed the database connection after the first pulldown get rid of the mysql_close($dbc); Link to comment https://forums.phpfreaks.com/topic/50191-solved-sorry-but-this-code-is-driving-me-nuts-can-some-one-please-help/#findComment-246410 Share on other sites More sharing options...
karatekid36 Posted May 6, 2007 Author Share Posted May 6, 2007 Thanks Ben! All set. Link to comment https://forums.phpfreaks.com/topic/50191-solved-sorry-but-this-code-is-driving-me-nuts-can-some-one-please-help/#findComment-246411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.