I need someone to help me with the following problem. I want to perform a select
on a MySQL database, the select will be done via Web service with PHP returning a Json for my Android app.
What happens, the user types login and password and the app recognizes the user and opens a second screen, in that second screen has a listview
and in that listview
should contain all the companies of that user, and it is at this point What is the problem? For me to do this I make a select
in PHP in the database, however, select
returns me all the companies of the database and not only that of the user who has logged in. I tried to save the company code using SESSION in PHP but it did not work, I would like someone to help me, thanks.
Follow the code in PHP:
<?php
SESSION_START();
echo $_SESSION['Cod_Empresa'];
mysql_connect('localhost','','');
mysql_select_db('bd') or die (mysql_error());
$result = mysql_query( "SELECT UC, Instalacao, Nome_Logo FROM Tab_UC where Cod_Empresa ='".$_SESSION['Cod_Empresa']."'") or die('Could not query');
for($rows = array(); $row = mysql_fetch_object($result); $rows[] = $row);
{
echo json_encode($rows);
}
?>