473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I want to use input from multiple drop downs and input the values into an sql table.

I have created a php page that is populated with information from the sql table module. From here i rank the modules using a drop down based on the amount of modules displayed. How do i go about saving these multiple value drops in conjunction with the student id and moduleID

this below is my code for the student menu
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4.         <title>Module Selector</title>
  5.         <style>
  6.             tr {background-color:lightblue;}
  7.             td {text-align:center;}
  8.     </style>
  9.     </head>
  10.     <body>
  11.     <h1> Rate The Modules in Order of Prefrence With 1 Being The Highest</h1> 
  12.     <form action= "<?php echo $_SERVER['PHP_SELF']; ?>"  method="post">
  13.         <?php
  14.  
  15.             require_once "./includes/connection.inc.php";
  16.             $conn = dbConnect();
  17.             //echo 'connected';
  18.             //Ruth Gammack - prepare statement to count the number of modules available for student
  19.                 $sel = $conn->prepare('select count(*) from module student where student.courseID = courseID');
  20.  
  21.                 $sql = "SELECT * FROM module student WHERE student.courseID = courseID";
  22.                 $stmt = $conn->prepare($sql);
  23.  
  24.             try {
  25.                 $stmt->execute();
  26.                 $sel->execute();
  27.  
  28.                 $results = $stmt->fetchAll();
  29.                 $count = $sel->fetchColumn();
  30.  
  31.                 if (!$results){ // check we have some results
  32.                     echo "No modules Available at this time please try again later <br />";
  33.                 }
  34.                 else{    //generate table of modules
  35.                     print "<table>\n";
  36.                     echo "<th>ModuleID</th><th>Name</th><th>Description</th><th>Lecturer</th><th>Ranking</th>";   
  37.                     {
  38.                     foreach ($results as $row){
  39.  
  40.                         echo "<tr>";
  41.                         echo "<td>".$row["moduleID"]."</td>";
  42.                         echo "<td>".$row["ModuleName"]."</td>";
  43.                         echo "<td>".$row["ModuleDesc"]."</td>";
  44.                         echo "<td>".$row["LecturerID"]."</td>";
  45.                         //Display a dropdown for each module selected for the user from the database
  46.                            echo "<td><select name='modRankDropdown'>";
  47.                         //Ruth Gammack- using a temp count = to the count returned from the database
  48.                         $tempcount = $count;
  49.                             //while the count is more than 0 echo the temp count in the option box and the decrement by one
  50.                             while ($tempcount > 0){
  51.                                 echo "<option value='".$tempcount."'>".$tempcount."</option>";
  52.                                 $tempcount--;
  53.                             }
  54.                         echo"</select></td>";
  55.                     }
  56.                   }
  57.                     echo "</table>";
  58.  
  59.                     echo "<br> Confirm Modules: <INPUT TYPE = 'Submit' Name = 'Submit' VALUE = 'Submit'>";
  60.  
  61.                 }
  62.             } catch ( PDOException $e ) {
  63.                 echo "Query failed: " . $e->getMessage();
  64.             }
  65.             // close database connection
  66.             dbClose($conn);
  67.        ?>
  68.         </form>
  69.         <a href="choices.php?action=viewChoices">View Choices</a>
  70.     </body>
  71. </html>
  72.  
  73.  
  74.  
Dec 5 '11 #1
0 1057

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Kim14 | last post by:
Help! I am trying to create a webpage and it would be obvious to anyone who reads my source code (it's a mess) that I created it using a template. I know almost nothing about webpages, but am...
1
by: Mike | last post by:
I have 2 drop downs on my web page and this will allow the user to filter the data on one drop down or both. How can I link these dropdowns together to allow the user to filter on one or both? ...
2
by: Woody Splawn | last post by:
I have a question about technique with regard to filling drop downs. I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I...
0
by: jmawebco | last post by:
I would like to know of anyone could tell me if the following is possible; I want to create a user control that will retrieve data from a database and create 4 seperate dropdown lists. The data...
3
by: CSharpguy | last post by:
I have 3 drop downs that are populated from the databasem 4 of my web pages need to have this drop down, how can I trap the selection made in the drop down and popuate my grid on my form?
4
by: teknoshock | last post by:
I have created a page with multiple drop down boxes, all populated with the same options. My problem is, for 12 dropdown boxes and 40 choices per box, I end up with a massive file. Also, if I...
6
by: bdockery | last post by:
Here’s the deal. I'm more of a general Microsoft Admin, so I'm new to Access. My boss wants some type of PO request and tracking system setup, so I read a book on Access since it seems to be the...
0
by: ehsanen | last post by:
I have some text boxes and drop downs on my web page and now i want to put a button in my webpage that when the user clicked the buton the page itself add another row of textboxes and drop downs , in...
2
by: comerica1 | last post by:
I have the basic structure as follows: 2 drop downs A & B. A is populated using (datasource methods - from database). B is poulated using A's selected value as input and retrieve the list...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.