'PHP export data from sql to excel
I have some problem when i try to get data from SQL and save it on excel, i want to download only the data from the login user, from the session.
This is an example of what i want to do:
$query = ("SELECT * FROM tickets_list WHERE UserName = '".$_SESSION['useruid']."'");
$result = mysqli_query($conn, $query);
The top code is not working... what is working is:
$query = ("SELECT * FROM tickets_list");
$result = mysqli_query($conn, $query);
But i don't want to get in the excel file from all the users..
Can anyone please tell me what i do wrong?
Thank you in advance!
Solution 1:[1]
I think your mistake in SQL, You are searching Username by UserId. That's why it shows this.
$query = ("SELECT * FROM tickets_list WHERE UserName
='".$_SESSION['username']."'");
$result = mysqli_query($conn, $query);
Please, check this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
