查询mysql中的多行作为变量[duplicate]

Possible Duplicate:
PHP - Simple way to read single record from MySQL

I want to query multiple rows in mysql as variable. for example:

SELECT name, tid FROM term_data WHERE vid = 2

this is the result:

name | tid
-----|----
Jack | 55
Tony | 87
John | 32

then I want to use while:

while (...) {

print "My name is: $name and my ID is: $tid";
//name and tid should be printed from database. 

}

I can query one row and put it in a while but How is this possible?

enter image description here

Example from the PHP manual:

<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s
", mysqli_connect_error());
    exit();
}

$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";

if ($result = mysqli_query($link, $query)) {

    /* fetch associative array */
    while ($row = mysqli_fetch_assoc($result)) {
        printf ("%s (%s)
", $row["Name"], $row["CountryCode"]);
    }

    /* free result set */
    mysqli_free_result($result);
}

/* close connection */
mysqli_close($link);
?>
<?php
//Conection
...
$query= "SELECT name, tid FROM term_data WHERE vid = 2";

if (query_run=mysql_query($query)) {
while ($query_row=mysql_fetch_assoc($query_run)) {
$name=$query_row['name'];
$tid=$query_row['tid'];

echo 'My name is'.$name.'and my ID is'.$tid;
}
}
else {
echo mysql_error();
}
?>

Only thing remains is resolving the connection which is up to you.