R. Purcell
R. Purcell

Reputation: 1

"HTML Form Select Tag Issue: Only First Word of Multi-Word Selections Inserted into MySQL Table"

A single HTML select tag is populated by a MySQL database table. When a user selects an option containing multiple words and submits it, only the first word of the selection is saved.

This is the code for the HTML form:

<form action="submit_page.php" method="post">
    <label for="type_name">Transaction Type</label>
    
    <select name="type_name" id="type_name" required>
        <option class="select" disabled="" selected="">Select type...</option>
        

      <?php foreach ($rows as $row) {
         echo "<option value = ". $row['type_name'] . ">" . $row['type_name'] . "</option>";
                
      } ?>  
   </select> <br><br>

   <input type="submit" value="Submit" />

Upvotes: 0

Views: 12

Answers (0)

Related Questions