How can i save various IDs obtained by a SQL ql query in one array - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How can i save various IDs obtained by a SQL ql query in one array (
/showthread.php?tid=600396)
How can i save various IDs obtained by a SQL ql query in one array -
Minikole - 07.02.2016
Hello guys, i have a question. How can i save IDs obtained by a sql query in one array? (Various IDs obtained in one query)
This is an example of one random table and this is the format of the query
(SELECT ID FROM table WHERE Nombre='Minikole')
ID | Nombre |
4 | Minikole |
8 | Minikole |
14 | Minikole |
I would save those IDs in array[3] (for example), something like this:
array[0] = 4;
array[1] = 8;
array[2] = 14;
This is all, thank you very much for the help.
Re: How can i save various IDs obtained by a SQL ql query in one array -
AbyssMorgan - 07.02.2016
Example:
PHP код:
#define MAX_SLOTS (50)
new buffer[256], i = 0;
format(buffer,sizeof buffer,"SELECT ID FROM table WHERE Nombre='Minikole' LIMIT %d",MAX_SLOTS);
mysql_query(buffer);
mysql_store_result();
while(mysql_retrieve_row()){
array[i] = //<-- save id here
i++;
}
mysql_free_result();
Respuesta: Re: How can i save various IDs obtained by a SQL ql query in one array -
Minikole - 07.02.2016
Quote:
Originally Posted by AbyssMorgan
Example:
PHP код:
#define MAX_SLOTS (50)
new buffer[256], i = 0;
format(buffer,sizeof buffer,"SELECT ID FROM table WHERE Nombre='Minikole' LIMIT %d",MAX_SLOTS);
mysql_query(buffer);
mysql_store_result();
while(mysql_retrieve_row()){
array[i] = //<-- save id here
i++;
}
mysql_free_result();
|
thank you very much for the help, i have an aditional question more. in
array[i] = how can i obtain the ID, using
mysql_fetch_field_row or using
cache_get_field_content_int?
Re: How can i save various IDs obtained by a SQL ql query in one array -
AbyssMorgan - 07.02.2016
yes
array[i] = cache_get_field_content_int(...);
Respuesta: Re: How can i save various IDs obtained by a SQL ql query in one array -
Minikole - 07.02.2016
Quote:
Originally Posted by AbyssMorgan
yes
array[i] = cache_get_field_content_int(...);
|
in the parameter
row, which be it? var i ?