Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Trouble with Pulldown Menu

5:00 pm on May 9, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:May 7, 2008
votes: 0

I have a pulldown menu that is being made to correspond with a MySQL database through PHP. It should be very simple but for some reason the HTML I am using for the structure of the pulldown menu is just disappearing on the web page. The HTML is between two different <?php ?> things. Here is the entire script with --> pointing towards the HTML that is disappearing:

include 'login.php';

$name = trim($_POST['name']);
$adviser = trim($_POST['adviser']) OR DIE ("MESSAGE!");
$year = trim($_POST['year']);
$first = trim($_POST['first']);
$second = trim($_POST['second']);
$third = trim($_POST['third']);
$fourth = trim($_POST['fourth']);
$fifth = trim($_POST['fifth']);
$sixth = trim($_POST['sixth']);
$seventh = trim($_POST['seventh']);
$eighth = trim($_POST['eighth']);

$query = "INSERT INTO schedule(name,
VALUES ('$name',
mysql_query($query) or die('YOUR FIELD WAS TO LONG!');

header('Location: schedule.php');
} }
<title>Make Your Own Schedule</title>
<link href="schedule.css" rel="stylesheet" type="text/css">
<div class="right">
<br><br><br><h3><div class="titlez3"><center>Search by Name: <form method="post" action="output.php"><input type="text" name="searchname" size="30"><input type="submit" value="GO"></form></center></div></h3>
<h3><div class="titlez4"><center>Search by Class: <br /><form method="post" action="searchclass.php"><input type="text" name="searchclass" size="30"><input type="submit" value="GO"></center></div></h3>
<h3><div class="titlez5"><center>Search by Year at CFS: <br /><input name="searchclassmen" type="text" size="30" maxlength="50"></center></div></h3>
<div class="left">
<h1><div class="titlez2"><center>Make a New Schedule:</center></div></h1>
<form method="post" name="schedule" action="schedule.php">
<div class="labelz">Name:</div>
<div class="fieldz">
<input name="name" type="text" size="50" maxlength="50">
<div class="labelz">Year at CFS:</div>
<div class="fieldz">
<input type="radio" name="year" value="Freshmen">Freshmen
<input type="radio" name="year" value="Sophomore">Sophomore
<input type="radio" name="year" value="Junior">Junior
<input type="radio" name="year" value="Senior">Senior
<div class="labelz">Adviser:</div>
<div class="fieldz">
<select name="adviser">
<option value="null" selected>--Select Your Adviser--</option>
<option value="Dave Worden">Dave Worden</option>
<option value="Rob LaVelle">Rob LaVelle</option>
<option value="Ken Mitchell">Ken Mitchell</option>
<option value="Frances Brindle">Frances Brindle</option>
<option value="Jamie Hysjulien">Jamie Hysjulien</option>
<option value="Bryce Little">Bryce Little</option>
<option value="Willy Rotella">Willy Rotella</option>
<option value="Elise London">Elise London</option>
<option value="Jon Lepofsky">Jon Lepofsky</option>
<option value="Susan Kincaid & Tim O'Hara">Susan Kincaid & Tim O'Hara</option>
<option value="Guillermo Parra">Guillermo Parra</option>
<option value="Amelia Shull">Amelia Shull</option>
<option value="Carrie Huff">Carrie Huff</option>
include 'login.php';
$query = "SELECT class
FROM classes
WHERE period='1'";
$result = mysql_query($query) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
--><div class="labelz">First Period:</div>
--><div class="fieldz">
--><select name="first">
--><option value="null" selected>Select Your Adviser</option>
--><option value="<?php print " {$row['class']} ";?>"><?php print " -->{$row['class']} "; ?></option></select>
<div class="labelz">Second Period:</div>
<div class="fieldz">
<input name="second" type="text" size="50" maxlength="50">
<div class="labelz">Third Period:</div>
<div class="fieldz">
<input name="third" type="text" size="50" maxlength="50">
<div class="labelz">Fourth Period:</div>
<div class="fieldz">
<input name="fourth" type="text" size="50" maxlength="50">
<div class="labelz">Fifth Period:</div>
<div class="fieldz">
<input name="fifth" type="text" size="50" maxlength="50">
<div class="labelz">Sixth Period:</div>
<div class="fieldz">
<input name="sixth" type="text" size="50" maxlength="30">
<div class="labelz">Seventh Period:</div>
<div class="fieldz">
<input name="seventh" type="text" size="50" maxlength="30">
<div class="labelz">Eighth Period:</div>
<div class="fieldz">
<input name="eighth" type="text" size="50" maxlength="30">
<div class="titlez1"><center><input name="btnSign" type="submit" value="Make Schedule"></center></div></form></div>

5:10 pm on May 9, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Feb 4, 2004
posts: 215
votes: 0

You may not be getting any results from your database.
after your query:
$result = mysql_query($query) or die("Couldn't execute query.");

check the number of results in the $result object using

1:44 pm on May 10, 2008 (gmt 0)


WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
votes: 0

also, instead of putting this

$result = mysql_query($query) or die("Couldn't execute query.");

which doesn't tell you why the query died

use this
$result = mysql_query($query) or die("Couldn't execute query: " . mysql_error());

this will return the error from mysql and help you find the problem

4:45 pm on May 10, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:May 7, 2008
votes: 0

Oh! Alright the problem was that I didn't have anything in the table "classes".... ugh...

[edited by: Spiceydog at 4:46 pm (utc) on May 10, 2008]

[edited by: coopster at 1:31 am (utc) on May 15, 2008]
[edit reason] general [/edit]

4:51 pm on May 10, 2008 (gmt 0)


WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
votes: 0


happens to all of us, glad you found it :)


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members