Guest User

Untitled

a guest
Aug 10th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. $servername = "localhost";
  2. $username = "root";
  3. $password = "";
  4. $dbname = "names";
  5.  
  6. <div>
  7. <?php
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. if ($conn->connect_error) {
  10. die("Connection failed: " . $conn->connect_error);
  11. }
  12. $sql = "SELECT * FROM surnames";
  13. $result = $conn->query($sql);
  14.  
  15. if ($result->num_rows > 0) {
  16. echo "surnames ID : ";
  17. echo "<select name='surnamesoption' id='surnamesoption' >";
  18. while($row = mysqli_fetch_array( $result )) {
  19. echo '<option value = "'. $row['ID'] . '">' . $row['surnames'] . '</option>';
  20. }
  21. echo "</select>";
  22. }
  23. ?>
  24. </div>
  25. <?php
  26. echo ** the sub string data of the option that is selected**
  27. ?>
Add Comment
Please, Sign In to add comment