Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //database settings
- $hostname="localhost";
- $database="alex";
- $username="root";
- $password="";
- $mysqli = new mysqli($hostname,$username,$password,$database);
- //query
- $query = "SELECT `useerName FROM `users`";
- $result = $mysqli->query($query);
- //process result
- $result_array=array();
- while($row = $Result->fetch_assoc())
- {
- $Result_Array[] = $row;
- }
- ?>
- Hope the below code helps:
- <?php
- $servername = "localhost";
- $username = "your username";
- $password = "your password";
- $dbname = "your dbname";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $getname= $_POST['name'];
- $sql = "SELECT userName FROM users WHERE userName LIKE '%$getname%';
- $result = mysqli_query($conn, $sql);
- if ($result->num_rows > 0) {
- echo "<table><tr><th>Name</th></tr>";
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<tr><td>" . $row["userName"]. "</td></tr>";
- }
- echo "</table>";
- } else {
- echo "0 results";
- }
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement