Posts: 1,648
Threads: 482
Joined: Jun 2010
alright,
Say a table in MySQL was called criminal records
Alright, if someone has a row in there it contains information regarding their criminal record.
I.e crime, officer arranged, time, date etc.
So...
If I do a MySQL query and it finds that there are 2 rows (records) matching that persons name then how could I make a maximum of 10 display in a dialog?
Like this:
Showing LATEST 10 records:
Crime here
Crime here.
Because they only have two records how can I like only make it show 2, as in if the maximum is 10 how can I SHOW the latest 10 or most recent, without showing them all, I'm confused by this...
Posts: 1,464
Threads: 90
Joined: Aug 2009
Reputation:
0
Use LIMIT <amount to show>,<starting row> at the end of your query.
Example:
SELECT * FROM criminal_records WHERE name = '%s' ORDER BY time ASC LIMIT 10,0
That would select all fields and rows from the table criminal_records, order them by their recorded time in ascending order, and limit the results to only show the first 10 criminal records.
Posts: 1,648
Threads: 482
Joined: Jun 2010
Would that mean I'd have to save the time?
Also yeah that covers the MySQL part but what about the dialog? How do I do it without the listitem 1 etcccc?
Posts: 1,648
Threads: 482
Joined: Jun 2010
As in,
pawn Код:
if(listitem == 1)
{
//Code Here
}
Instead of me having to like uhm actually add individually...I use a string,
so say there are 10 rows, do I have to do something like:
pawn Код:
if(rows == 1)
{
format(string, sizeof(string), "%s", CriminalRecord(mysqlresulthere));
}
if(rows == 2)
{
format(string, sizeof(string), "%s\n%s", CriminalRecord, CriminalRecord.));
}
How can I do the above without having to do if(mysql_rows == 1, == 2 == 3) etc and just do it as it is?
Posts: 1,464
Threads: 90
Joined: Aug 2009
Reputation:
0
Format the output from the query into a string and then parse it, yes. However with listitems (just looked real quick on the wiki) I don't understand what you're exactly trying to do now. From what I'm understanding you just want to list the latest 5 results, and that's it. Nothing more, right?
Posts: 1,648
Threads: 482
Joined: Jun 2010
Quote:
Originally Posted by Toni
Format the output from the query into a string and then parse it, yes. However with listitems (just looked real quick on the wiki) I don't understand what you're exactly trying to do now. From what I'm understanding you just want to list the latest 5 results, and that's it. Nothing more, right?
|
How do I parse it?
As in, I uhm, Basically trying to make a relatively dynamic way of doing it, like
Yeah, latest 5 results, but what if there isn't 5 results to be listed?