Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function showUser($id){
- $("#email").keyup(function(){
- $.ajax({
- type: "POST",
- url: "http://localhost/cart/guser.php",
- data:'keyword='$id,
- success: function(data){
- $("#txtHint").html(data);
- }
- });
- });
- }
- </script>
- <!DOCTYPE html>
- <html>
- <body>
- <form>
- enter digit :
- <input type="text" id="id" name="id" onkeyup='showUser(this.value)'/>
- <br />
- </form>
- <br>
- <div id="txtHint"><b>Person info will be listed here...</b>
- </div>
- <script>
- function showUser(id) {
- httpRequest = new XMLHttpRequest();
- if (!httpRequest) {
- alert('Giving up :( Cannot create an XMLHTTP instance');
- return false;
- }
- else
- {
- httpRequest.onreadystatechange = function() {
- if (httpRequest.readyState == 4 && httpRequest.status == 200) {
- document.getElementById("txtHint").innerHTML = httpRequest.responseText;
- }
- };
- httpRequest.open("GET", "localhost/cart/guser.php?id=" + id, true);
- httpRequest.send();
- }
- }
- </script>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table {
- width: 100%;
- border-collapse: collapse;
- }
- table, td, th {
- border: 1px solid black;
- padding: 5px;
- }
- th {text-align: left;}
- </style>
- </head>
- <body>
- <?php
- $id = intval($_GET['id']);
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "cart";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- mysqli_select_db('cart',$con);
- $sql="SELECT * FROM user_details WHERE id = '".$id."'";
- $result = mysqli_query($con,$sql);
- echo "<table>
- <tr>
- <th>Firstname</th>
- <th>Lastname</th>
- <th>email</th>
- </tr>";
- while($row = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>" . $row['FirstName'] . "</td>";
- echo "<td>" . $row['LastName'] . "</td>";
- echo "<td>" . $row['email'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- mysqli_close($con);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement