Andreu | 0b2f843 | 2019-09-18 20:09:59 +0200 | [diff] [blame] | 1 | <?php |
| 2 | // Define MySQL login variables |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame^] | 3 | $servername = "localhost"; // "fdb22.awardspace.net"; |
| 4 | $username = "root"; // "3155560_users"; |
| 5 | $password = ""; // "btechnoro@fox4news.info"; |
Andreu | 0b2f843 | 2019-09-18 20:09:59 +0200 | [diff] [blame] | 6 | |
| 7 | // Create connection |
Andreu | ed8e1f9 | 2019-09-18 22:26:04 +0200 | [diff] [blame^] | 8 | $conn = new mysqli($servername, $username, $password, "pastanaga"); |
Andreu | 0b2f843 | 2019-09-18 20:09:59 +0200 | [diff] [blame] | 9 | if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); |
| 10 | $conn->set_charset("utf8"); |
| 11 | |
| 12 | // Do the query |
| 13 | $query = "SELECT * FROM users"; |
| 14 | |
| 15 | // Fetch the information of the user |
| 16 | if ($result = $conn->query($query)) { |
| 17 | while ($row = $result->fetch_row()) { |
| 18 | $id = $row[0]; |
| 19 | $nomcomplet = $row[1]; |
| 20 | $curs = $row[2]; |
| 21 | $grau = $row[3]; |
| 22 | $quimata = $row[4]; |
| 23 | |
| 24 | // Echo the options |
| 25 | echo "<option value='".$id."'>".$nomcomplet."</option>\n"; |
| 26 | } |
| 27 | $result->close(); |
| 28 | } else { |
| 29 | die("Wrong query: " . $query); |
| 30 | } |
| 31 | |
| 32 | // Close connection |
| 33 | $conn->close(); |
| 34 | ?> |