Code: Select all
-- use a global variable to hold the connection ID so other scripts can use it
global gConnectionID
-- set up the connection parameters - edit these to suit your database
put "cmsni" into tDatabaseAddress
put "databasename" into tDatabaseName
put "username" into tDatabaseUser
put "password" into tDatabasePassword
-- connect to the database
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
put tResult into gConnectionID
put "town" into tTableName -- set this to the name of a table in your database
put "SELECT * FROM " & tTableName & " WHERE id=2" into tSQL
put "foodplace" into tTableName2 -- set this to the name of a table in your database
put "SELECT * FROM " & tTableName2 & " WHERE townid=1" into tSQL2
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL2) into tData2
put tData into field "Data"
put tData2 into field "Data2"
answer line 1 of tData i was told this was one way of achieveing this but this just prints each line instead of the field id or title contents