-1
I need someone to help me with the following problem. I want to realize a select
in a Mysql database, select will be done via web service with PHP returning a Json to my Android app.
What happens, the user enters login and password and the app recognizes the user and opens a second screen, in this second screen has a listview
and in that listview
should contain all the companies of that user, and it is at this point that this the problem. For me to do this I realize a select
in PHP in the database, however, select
returns me all companies in the database and not only the user who 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);
}
?>
and how it would be to filter by ID... could return me an example... thank you
– Tiago