2014년 12월 11일 목요일

How to fetch data from sql database server in multiple screens?


I was started programming with app inventor before few weeks ago..

Now a days, I am trying to upload and fetch data on my sql database server. and i m successful to upload data on sql database. but unable to fetch data form sql database that's why, I want to know how to fetch data in app inventor from sql database server. In O'Reilly book, he shows how to upload, fetch and update data on sql database server but in single screen with list picker. and i want to fetch data in multiple screen.but i didn't understand how to fetch data in multiple screen..

please give me some suggestion.

--
Data that is one one screen in App Inventor does not transfer automatically to another screen unless the developers instructs the app to do so.  Each screen in AI2 acts like a separate app, that can communicate with all the other sibling screens within the master app.   However, the developer has to code to allow this to happen; usually this is done with a TinyDb  and sharing the Tags among the screens for which other instances of a TinyDB have been placed.    What this means is if you are 'fetching' data using Screen1, you have to transfer that data to Screen2 if you want to use it on that screen.   Possibly your problem Mayank.

--
Thank you for your response. but dear this is not my problem i am using an online SQL database server to upload details but i am facing problem in fetching content from database CSV file.. I don't understand how to fetch in app inventor I hope you are getting my point please help!!!!

--
How are you fetching data from sql server?  I'm guessing that you are reading a csv file or ?  I'm sorry, please provide more info.

--

I am using php script to upload and fetch data from sql database server. this image is for uploading data..
but i dont understand how to use blocks to get this details in another screen.

for uploading data php script-
<?php
DEFINE ('DBUSER', 'UserName');
DEFINE ('DBPW', 'Password');
DEFINE ('DBHOST', 'HostName');
DEFINE ('DBNAME', 'DBName');

$dbc = mysqli_connect(DBHOST, DBUSER, DBPW) or die("Database Connection Failed");

$dbs = mysqli_select_db($dbc, DBName or die("Could not select the database");

$MobileNumber = mysql_real_escape_string($dbc, $_GET['MobileNumber']);
$Name = mysql_real_escape_string($dbc, $_GET['Name']);
$Email = mysql_real_escape_string($dbc, $_GET['Email']);
$Password = mysql_real_escape_string($dbc, $_GET['Password']);

$query = "INSERT INTO details(mobilenumber, name, email, password) VALUES ('$MobileNumber', '$Name', '$Email', '$Password')";

$result = mysqli_query($dbc, $query) or die("Query MySQL Error");


?>

And for retrieve data in another screen php script-

<?php
DEFINE ('DBUSER', 'UserName');
DEFINE ('DBPW', 'Password');
DEFINE ('DBHOST', 'HostName');
DEFINE ('DBNAME', 'DBName');

$dbc = mysqli_connect(DBHOST, DBUSER, DBPW) or die("Database Connection Failed");

$dbs = mysqli_select_db($dbc, DBName or die("Could not select the database");

$result = mysql_query($dbc, "SHOW COLUMNS FROM DETAILS");
$numberOfRows = mysql_num_rows($result);
if($numberOfRows > 0){
$values = mysql_query($dbc, "SELECT * FROM details WHERE mobilenumber='mobilenumber'");
while($rowr = mysql_fetch_row($values)){
for($j=0; $j<$numberOfRows; $j++){
$csv_output .= $rowr[$j]. ", ";
}
$csv_output .= "\n";
}
}
print $csv_output;
exit;

exit;
?>

--
I would wait until I get the result from the web component back in the web.GotText event before opening another screen...


--
but web1.GotText event can be done on another screen where i want to display result from sql database server.

can you show me a example of blocks???

--
you have 2 possibilities:
1. first go to the other screen, then get the data from the server and receive the result it in the web.got text event and display it, or
2. first get the data and get the result back in the web.got text event, then store the result in TinyDB or pass the result to the other screen using the open another screen with value block and display it there

--

댓글 없음:

댓글 쓰기