logo
down
shadow

Get value from a dropdown list and insert it in the database


Get value from a dropdown list and insert it in the database

By : user2953929
Date : November 21 2020, 07:31 AM
Hope that helps This is a bit of a mess, so this might be a messy post, but I'll try to clarify what I think you're trying to do. For your select input:
code :
<select id="SelectDisease" name="disease">
<?php
  $sql = mysql_query("SELECT name FROM disease");
  while ($row = mysql_fetch_array($sql)){
    echo "<option value='".$row['name']."'>".$row['name']."</option>";
  }
?>
</select>
$fname = $_POST['fname'];
$lname = $_POST['lname'];
... // Etc for each input you have.
$disease = $_POST['disease'];
queryMysql("INSERT INTO patient 
(fname,lname,username,email,password,gender,age,disease,spid) 
VALUES('$fname','$lname','$username','$email', '$password','$PatientG','$PatientAge','$disease','$PatientSPID')");


Share : facebook icon twitter icon
retrieve dropdown list from mysql database and insert to database in jsp

retrieve dropdown list from mysql database and insert to database in jsp


By : krononflex
Date : March 29 2020, 07:55 AM
Does that help You've it almost right. To get the dropdown values from a database you should first call the servlet which does the preprocessing job and then let the servlet display the JSP with the dropdown.
Since a normal HTTP request (clicking a link, a bookmark or entering the URL in address bar) fires per definition a GET request, you'd like to do the job in the doGet() method. Here's an example which gets the dropdown values in flavor of a List.
code :
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    List<Product> products = productService.list();
    request.setAttribute("products", products); // It'll be available as ${products}.
    request.getRequestDispatcher("/WEB-INF/products.jsp").forward(request, response);
}
<form action="order" method="post">
    <select name="productId">
        <c:forEach items="${products}" var="product">
            <option value="${product.id}">${product.name}</option>
        </c:forEach>
    </select>
    <input type="submit" value="Order" />
</form>
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String productId = request.getParameter("productId");
    // ... do your job here to insert the data.

    request.getRequestDispatcher("/WEB-INF/someresult.jsp").forward(request, response);
}
(newbie post) PHP dropdown list, to insert a value from a dropdown list into database

(newbie post) PHP dropdown list, to insert a value from a dropdown list into database


By : Adam Rollo
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further could someone please help me with this problem, sorry for the Language in the code. Im trying to make it that way, that when someone selects a option and clicks the button that it will be inserted into my database, I already checked out if the name are all correct and such, and they are. , 1) In your select don't give names to each option
code :
<select name="room" value="options">
<option value="Einstaklings">Alment Einstaklings Herbergi</option>
<option value="Tveggja">Alment Tveggja manna Herbergi</option>
<option value="Business">Business Herbergi</option>
<option value="Fjolskyldu">Fjölskyldu Herbergi</option>
<option value="Svitu">Svítu</option>
</SELECT>
<?php 
   $room = $_POST['room'];
?>
how to insert data from dropdown list to database

how to insert data from dropdown list to database


By : Rossi
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Change your form action to the name of the current file. Then at the top of your file open the following IF statement:
code :
if ($_SERVER['REQUEST_METHOD']=='POST'){
$variable = $_POST['name_of_select'];
How to insert dropdown list option into database

How to insert dropdown list option into database


By : Emanuel Raymond
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You do not need link select option as input type. All you need is add name to the select element and add value for option element as:
code :
<tr>
    <td>Crew Name:</td>
    <td>
        <input type="text" name="CrewName" id ="CrewName" required />
    </td>     
</tr>
<tr>
    <td>Crew Rank:</td>
    <td>
        <select name="CrewRank" id="CrewRank">
        <?php
             $con = getDbConnect();
             if (!mysqli_connect_errno($con)) {
                 $queryStr = "SELECT rank " .
                             "FROM rankpage";

             }

             $result = mysqli_query($con, $queryStr);

             while ($row = mysqli_fetch_array($result)) {
                    echo "<option value=\"" . $row['rank'] . "\">" . $row['rank'] . "</option>";
             }
         ?>
         </select>
     </td>       
</tr>
I want to insert data into my dropdown list from database

I want to insert data into my dropdown list from database


By : john doe
Date : March 29 2020, 07:55 AM
I wish this help you First you must provide data for your dropdown (select) in a controller -> action like this. I've suppose you have an action called Create and you have a model with Name and Id properties, so:
code :
 public ActionResult Create()
        {
            var ListData = _db.ListData.ToList();
            ViewBag.List = new SelectList(ListData, "Id", "Name", "0");
            return View();
        }
@Html.DropDownListFor(m => m.[use a viewModel to set data], (SelectList)ViewBag.List, new {});
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org