I have mysql
db with different tables. The data between the tables are linked and I retrieve and display them by using the userid. I used the reference from PHP MYS
You have to give it an array so try it like this
$con=mysqli_connect("localhost","root","","mytable");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT user_id FROM tbl_users";
$users_profile_user_id = mysqli_query($con, $sql);
$fp = fopen("user_profile_id.csv", "w");
while($row = mysqli_fetch_array($users_profile_user_id, MYSQLI_ASSOC)){
fputcsv($fp, $row);
}
fclose($fp);