?
Solved

Drop Down boxes from MYSQL

Posted on 2003-03-29
5
Medium Priority
?
223 Views
Last Modified: 2010-04-01
I'm trying to get drop down box with the date of the past 10 days. I'm pulling the information from the food_eaten table and the name of the field is date_eaten. The code below is what i have at the moment and need some pointers in the right direction because the code is not working. Also when i have the code, how do i keep track of what date the user has chosen(1 thru 10)?

<%
     Connection dbconn;
     try
     {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          try
          {              
               dbconn = DriverManager.getConnection("jdbc:mysql://localhost/nutrition","saundersk","kevin");
               out.println("Connected");
                   
         
          <select name=date>
          <%
         
         
          Statement stmt = dbconn.createStatement();
          ResultSet rs = stmt.executeQuery("select date_eaten from food_eaten");
         
          while (rs.next())
          {
               %>
               <option value="<%= rs.getString("date_eaten") %>"><%= rs.getString("date_eaten") %>
               <%
          }
          rs.close();
          stmt.close();
          con.close();
          %>
         
          </select>
         
          }          
          catch (SQLException s)
          {
               out.println("SQL Error<br>");
          }
     }
     catch (ClassNotFoundException err)
     {
          out.println("Class loading error");
        }
%>
0
Comment
Question by:sredmusarm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 60 total points
ID: 8230950
first, i'd stay away from using names like date b/c it's a reserved word:

<select name=date>

also,
con.close();

should be

dbconn.close();

what exactly isn't working?
0
 

Author Comment

by:sredmusarm
ID: 8231052
Thanks for the start...The error that apache is giving me is illegal start of expression and then underneath that it gives me the picture of a drop down box?
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 8231332
what's the extension of your page? it should be *.jsp

i don't see anything wrong with the above code.

0
 

Author Comment

by:sredmusarm
ID: 8231572
yeah the extension is .jsp
0
 

Author Comment

by:sredmusarm
ID: 8231602
yeah the extension is .jsp
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
Introducing Priority Question, our latest feature.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question