Php变量优先

I've one issue about php variable. Let's example:

This is my while loop which i want to edit user contact list.

$sql = mysql_query("SELECT * FROM addcontacts WHERE name LIKE 'a%' AND uname = 
'$uname'");

while($re = mysql_fetch_array($sql))
{
$id = (int) $re['id'];  
$name = mysql_real_escape_string(htmlspecialchars(trim($re['name'])));
$surname = mysql_real_escape_string(htmlspecialchars(trim($re['surename'])));
$group = mysql_real_escape_string(htmlspecialchars(trim($re['group'])));
$email =  mysql_real_escape_string(htmlspecialchars(trim($re['email'])));
$skype = mysql_real_escape_string(htmlspecialchars(trim($re['skypeid']))); 
$facebook = mysql_real_escape_string(htmlspecialchars(trim($re['facelink']))); 
$twitter = mysql_real_escape_string(htmlspecialchars(trim($re['twitterlink'])));
$aim = mysql_real_escape_string(htmlspecialchars(trim($re['aimid'])));
$myspace = mysql_real_escape_string(htmlspecialchars(trim($re['myspacelink'])));
$notes = mysql_real_escape_string(htmlspecialchars(trim($re['specialnote'])));

more code......
?>

So my questions is, Is there anyway to access this $id before $sql query ? I need this $id value to the top of the form because of there are a button name: Edit Contacts. So if i get this $id value then i can edit user contact list.

No. The ID comes from the database, so you must perform some query before you can get it.

Your $id is the id given from the MySQL record. As far as I understood your question, you would need to do your query before building the form.

You said

I need this $id value to the top of the form because

So I assume there is a bit of a bad design. You need the form to update a record? If so, you should call the form with the id (or id's) of the record given that you want to modify.