You asked about experience, I am very new to livecode, I have been playing with it for 2 weeks now..
I was trying to make my question simple but I think I made it harder.
I have been working with the livecode - Connecting to a MySQL database tutorial. and I have a database with 19 tables.
Here is my code, its probably sloppy, try not to make fun of me
Code: Select all
on closeField
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- edit these variables to match your database & table
-- this assumes a table called Table1 with 3 fields
put "tracker" into tTableName
put "trackerjob, trackercert" into tFields
put fld "jobn" into tJobN
put fld "certn" into tCertN
-- construct the SQL - the :1, :2 & :3 placeholders in the SQL will be filled by variables in the revExecuteSQL line
put "INSERT INTO " & tTableName & " (" & tFields & ") VALUES (:1, :2)" into tSQL
-- send the SQL to the database, filling in the placeholders with data from variables
revExecuteSQL gConnectionID, tSQL, "tJobN", "tCertN"
-- check the result and display the data or an error message
if the result is a number then
answer info "New record added."
else
put "SELECT * FROM " & tTableName & " WHERE trackercert=" & tCertN into tSQL
-- query the database
put revDataFromQuery(Tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
put item 1 of tData into field "view"
end if
end if
end closeField
at the very end there:
Code: Select all
else
put item 1 of tData into field "view"
end if
end if
end closeField
I get the data from one line in my data in a long string separated by space. ( I can change this to be tab or comma )
so right now as an example I get "1 2 3 4" in my tData variable
what i need instead is "1" in field "job", "2" in field "certn", "3" in field.... so on and so on
maybe there is a better way for me to query the database to fill in the fields.
This question at this point probably needs to be moved to the database forums