Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- --------------------------------------------------------------------------
- DATABASE
- --------------------------------------------------------------------------
- $host = 'localhost';
- $username = 'root';
- $password = 'root';
- $database = 'db1';
- $connection = mysqli_connect($host, $username, $password, $database);
- if (mysqli_connect_error($connection)) die('Error connecting');
- $emri = 'erald';
- $mbiemri = 'domi';
- if (!mysqli_query($connection, "INSERT INTO users (emri, mbiemri) VALUES ($emri, $mbiemri)")) die('Error adding user.');
- $result = mysqli_query($connection, "SELECT * FROM users;");
- if (mysqli_num_rows($result) > 0) {
- while ($row = mysqli_fetch_assoc($connection, $result)) {
- echo $row['emri'] . ' ' . $row['mbiemri'];
- }
- }
- mysqli_close($connection);
- --------------------------------------------------------------------------
- AJAX
- --------------------------------------------------------------------------
- ?>
- var req = new XMLHttpRequest();
- req.onreadystatechange = function () {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById('filan_id').innerHTML = this.responseText;
- }
- }
- req.open('GET', 'url', true);
- req.send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement