Jump to content

Database - to GUI


Eistee

Recommended Posts

Posted

Hello, i have a database (sql)

VUWEf.png

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 :)

Posted
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.

Posted

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: g2rpc.png

And thats in the table: VUWEf.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...