SQLite question
#1

Hello. I was wondering if it's possible to select a specific row(?)

Say I have a dialog(list) with the top players and want to select a row based on OnDialogResponse with listitem?

Example:
PHP код:
if(dialogid == DIALOG_TOP)
{
    if(
response) {
        
format(Query,sizeof(Query), "SELECT * FROM `USERS` ORDER BY `KILLS` DESC LIMIT 25");
        
Result db_query(DatabaseQuery);
        if(
db_num_rows(Result))
        {
            
db_select_row(listitem// function im looking for..? :d
            
db_get_field_assoc(Result"OwnerName"string48);
        }
    } 
And another issue, the query below doesnt give me any results, any ideas as to why?
PHP код:
format(Query,sizeof(Query), "SELECT * FROM `VEHDATA` WHERE `OwnerID` = %i ORDER BY `VehID` DESC LIMIT 15"PlayerInfo[playerid][UserID]); 
Thanks in advance!
Reply
#2

I do not understand.
Reply
#3

PHP код:
format(Query,sizeof(Query), "SELECT * FROM `VEHDATA` WHERE `OwnerID` = '%i' ORDER BY `VehID` DESC LIMIT 15"PlayerInfo[playerid][UserID]); 
Reply
#4

Quote:
Originally Posted by Yaa
Посмотреть сообщение
PHP код:
format(Query,sizeof(Query), "SELECT * FROM `VEHDATA` WHERE `OwnerID` = '%i' ORDER BY `VehID` DESC LIMIT 15"PlayerInfo[playerid][UserID]); 
What you did was add apostrophes and thats for strings, not integers. (afaik)

Quote:
Originally Posted by Speedpro
Посмотреть сообщение
I do not understand.
I'm looking for something that allows me to select a specific row from a query result, basically what "db_next_row" does but selects a specific row based on the "ORDER BY" order.

Another example:

(a list showing the top players in order)


In OnDialogResponse I want to perform a query that selects the correct row(based on the order by order) based off of what the user selected in the dialog.

I can see how this might sound confusing but I hope you understand(I might have to end up storing the values in variables, but I'd prefer not to)
Reply
#5

It is not possible to select a row directly, you will have to use db_next_row function. If you know that the limit is 25, then an array with that size and assigning the data to this array is the only way I can think of so you can easily access the element with index equal to listitem.

Based on your last example, what you're trying to do is send another query with the player selected? You can easily do this by using inputtext (which holds the text of the specific item) and retrieve the name (in your case strfind to get the pos of " -"; that'll be the end of the player's name). Last, execute the query with the name in WHERE clause.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It is not possible to select a row directly, you will have to use db_next_row function. If you know that the limit is 25, then an array with that size and assigning the data to this array is the only way I can think of so you can easily access the element with index equal to listitem.

Based on your last example, what you're trying to do is send another query with the player selected? You can easily do this by using inputtext (which holds the text of the specific item) and retrieve the name (in your case strfind to get the pos of " -"; that'll be the end of the player's name). Last, execute the query with the name in WHERE clause.
Thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)