D Dman Active Member Licensed User Longtime User Jan 19, 2014 #1 I have connected to the mysql database successfully using the demo in this topic http://www.b4x.com/android/forum/threads/connect-android-to-mysql-database-tutorial.8339/#content I can successfully retrieve, edit and update the existing information. I have not figured out how to get the max value from a field and insert the max value + 1 into an edittext when adding a new record.In other words, I can't figure out how to display the value in an edittext. I am thinking the select command is similar to the one below but I am confused on exactly how to display it. ExecuteRemoteQuery("SELECT MAX(number) as max_number FROM members", Get_Max) Last edited: Jan 19, 2014
I have connected to the mysql database successfully using the demo in this topic http://www.b4x.com/android/forum/threads/connect-android-to-mysql-database-tutorial.8339/#content I can successfully retrieve, edit and update the existing information. I have not figured out how to get the max value from a field and insert the max value + 1 into an edittext when adding a new record.In other words, I can't figure out how to display the value in an edittext. I am thinking the select command is similar to the one below but I am confused on exactly how to display it. ExecuteRemoteQuery("SELECT MAX(number) as max_number FROM members", Get_Max)
S sorex Expert Licensed User Longtime User Jan 19, 2014 #2 did you update the jobdone part? you'll need to add another case for the Get_Max command. there you can read out the response from the server, add 1 to it and store it in edittext.text something like Code: Copy Select Job.JobName Case Get_Max label1.text=job.getstring+1 End Select might nee a mod to label1.text=int(job.getstring)+1 tho Last edited: Jan 19, 2014 Upvote 0
did you update the jobdone part? you'll need to add another case for the Get_Max command. there you can read out the response from the server, add 1 to it and store it in edittext.text something like Code: Copy Select Job.JobName Case Get_Max label1.text=job.getstring+1 End Select might nee a mod to label1.text=int(job.getstring)+1 tho
D Dman Active Member Licensed User Longtime User Jan 19, 2014 #3 I did add another case for the Get_Max part. I inserted a messagebox to see what the value of job.getstring is and it shows [{"max_number":"6823"}] and if I take the "as max_number" out of the sql statement the value is [{"MAX(number)":"6823"}] Upvote 0
I did add another case for the Get_Max part. I inserted a messagebox to see what the value of job.getstring is and it shows [{"max_number":"6823"}] and if I take the "as max_number" out of the sql statement the value is [{"MAX(number)":"6823"}]
S sorex Expert Licensed User Longtime User Jan 19, 2014 #4 ok, you encoded it as a json collection so you'll need to parse it with an extra library. or you can comment that encode_json line in your php and just use echo $my_sqlfieldvalue; then you can use the code I provided a few minutes ago. Upvote 0
ok, you encoded it as a json collection so you'll need to parse it with an extra library. or you can comment that encode_json line in your php and just use echo $my_sqlfieldvalue; then you can use the code I provided a few minutes ago.
S sorex Expert Licensed User Longtime User Jan 19, 2014 #5 by the way you can also use this SELECT MAX(number)+1 FROM members Upvote 0
D Dman Active Member Licensed User Longtime User Jan 19, 2014 #6 If I comment the encode_json line in the php will that mess up all my other jobs that are working fine? Upvote 0
If I comment the encode_json line in the php will that mess up all my other jobs that are working fine?
S sorex Expert Licensed User Longtime User Jan 19, 2014 #7 only if all the other requests are in the same php file and you only used 1 json encode for all results. json/xml is mainly used to exchange datasets, for just 1 record or value like in your case you can just read out the response which is less hassle Upvote 0
only if all the other requests are in the same php file and you only used 1 json encode for all results. json/xml is mainly used to exchange datasets, for just 1 record or value like in your case you can just read out the response which is less hassle
D Dman Active Member Licensed User Longtime User Jan 19, 2014 #8 I only have 1 php file so I assume they are all there. Is there a way to get what I need by code? Upvote 0
S sorex Expert Licensed User Longtime User Jan 19, 2014 #9 I suggest you join the chat and pastebin you php and/or b4a code. http://www.mlsoft.org/b4achat/ Upvote 0
D Dman Active Member Licensed User Longtime User Jan 20, 2014 #10 Thank you sorex for fixing me up! Upvote 0