简体   繁体   中英

MYSQL/PHP Select A Users Ranks

Hi I have A MYSQL Database Thats Like This

|id|username|password|rank  |
|1 | jeff   | Passwor| admin|
|2 | bob    | passow | user |

how would i use php to fetch it and assign it a variable

I hope this can help your problem

<?php
$servername = "localhost";
$database = "contoh";
$username = "root";
$password = "root";

$conn = mysqli_connect($servername, $username, $password, $database);

$sql2 = 'SELECT * FROM `user_ranks`';
  $result2 = $conn->query($sql2);
      while($row = $result2->fetch_assoc()) {
          $id = $row['id'];
          $username = $row['username'];
          $password = $row['password'];
          $rank = $row['rank'];
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM