Eistee Posted April 13, 2013 Share Posted April 13, 2013 Hello, i have a database (sql) Full Picture:https://i.epvpimg.com/VUWEf.png How i can get the data of the database to put it into a gui window? Something like that: mysql_query(handler,"SELECT * FROM houses WHERE OWNER = '"..getPlayerName(player)"' ") I would to get the two houses of the player (picture) into a gui window... Please help Link to comment
Eistee Posted April 13, 2013 Author Share Posted April 13, 2013 so: local playern = getPlayerName(thePlayer) executeSQLQuery("SELECT houses WHERE OWNER=playern" ? Link to comment
iPrestege Posted April 13, 2013 Share Posted April 13, 2013 https://forum.multitheftauto.com/viewtopic.php?f=148&t=38203 Link to comment
Sasu Posted April 13, 2013 Share Posted April 13, 2013 MySQL and SQLite are different. So be careful. Link to comment
iPrestege Posted April 13, 2013 Share Posted April 13, 2013 ^ Ah i did not notice about it sorry . Link to comment
Eistee Posted April 13, 2013 Author Share Posted April 13, 2013 I have a phpmyadmin database Link to comment
codeluaeveryday Posted April 13, 2013 Share Posted April 13, 2013 dbConnect dbQuery Remember dbConnect returns the required element for dbQuery, when using dbConnect, add a variable to it. so: local session = dbConnect(...) and use session for the dbQuery argument 'databaseConnection'. I hope this helps you with your enquire. Link to comment
Eistee Posted April 13, 2013 Author Share Posted April 13, 2013 I connected it so: local mysqlhost1 = "localhost" local mysqluser1 = "viomax" local mysqlpassword1 = "viomax" local mysqldatabase1 = "viomax" local mysqlhost2 = "localhost" local mysqluser2 = "viomax" local mysqlpassword2 = "viomax" local mysqldatabase2 = "viomax" addEventHandler("onResourceStart", getResourceRootElement(), function() handler = dbConnect("mysql", "dbname="..mysqldatabase1..";host="..mysqlhost1, mysqluser1, mysqlpassword1, "autoreconnect=1") if not(handler) then outputServerLog("MySQL funktioniert nicht, versuche zweite Datenbank. Bitte warten...") handler = dbConnect("mysql", "dbname="..mysqldatabase2..";host="..mysqlhost2, mysqluser2, mysqlpassword2, "autoreconnect=1") if not(handler) then outputServerLog("Zweite Datenbank funktioniert nicht, beende...") cancelEvent() else outputServerLog("Zweite Datenbank akzeptiert!") housesys_startup() end else outputServerLog("Erste Datenbank akzeptiert!") housesys_startup() end end) In the database it looks so: The table: And thats in the table: Link to comment
Kenix Posted April 13, 2013 Share Posted April 13, 2013 You need make a query for get all data from your table. So you can use this functions dbQuery dbPoll When you get all data from query you need send it to client. Use a triggerClientEvent More info: https://wiki.multitheftauto.com/wiki/Event_system viewtopic.php?f=148&t=38203 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now