如何使用记录集格式化数组

I want to populate an array with data from a database. I need it to have different labels from what is stated in database as headers.

This is how I need it to be formatted

[ { label: "Choice1", value: "value1" }, ... ]

I have used this but then I'm getting the wrong labels

$items = array();
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) {
  $items[] = $row_Recordset1;
}

eg.

[{"ID":"2","ARTIST":"!!!"},...]

I need it like this to use the jquery ui plugin for autocomplete

You need to return the data as a JSON object...

$items = array();
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) {
  $items[] = array(
    'label' => $row_Recordset1['ARTIST'],
    'value' => $row_Recordset1['ID']
  );
}

return json_encode($items);

Also you should look at using PDO instead of MySQL_* functions as they are now deprecated.

Fetch assoc data from your database, put them into an array and use json_encode on the resultset.

You need to use the json_encode method on your associative array.