首先需要连接到MySQL数据库:
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
然后,要为特定ID选择数据:
if( $mysqli->query( "SELECT * FROM users WHERE ID = $ID" ) ) {
if( $result = $mysqli->use_result() ) {
while( $row = $result->fetch_assoc() ) {
echo $row['username'];
}
$result->close();
}
}