-4

How can i change this into mysqli?

// add meta_key to the query
$get_user_data = mysql_query("SELECT `meta_value`,`meta_key` FROM `table` WHERE `user_id` = $user_id", $link);

// use _assoc instead of _array, we do not need the numerical indexes.
while($row=mysql_fetch_assoc($get_user_data)){
  $userdata[$row['meta_key']] = $row['meta_value'];
}
Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

-1

Just simple changes you have to made in your code:

// add meta_key to the query
$get_user_data = mysqli_query($link,"SELECT `meta_value`,`meta_key` FROM `table` WHERE `user_id` = $user_id");

// use _assoc instead of _array, we don't need the numerical indexes.
while($row=mysqli_fetch_assoc($get_user_data))
{
     $userdata[$row['meta_key']] = $row['meta_value'];
}