Question regarding MySQL and dialogs.
#1

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...
Reply
#2

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.
Reply
#3

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?
Reply
#4

Quote:
Originally Posted by Dokins
Посмотреть сообщение
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?
You don't have to unless you plan on doing some sort of ordering, I'd assume you'd do it by latest time report. It's up to you.

I haven't done dialogs in a very long time, so I don't really know. However I'd assume it'd be assigning the results to an array then parsing it in a dialog menu. And what do you mean 'listitem 1 etcccccc'
Reply
#5

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?
Reply
#6

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?
Reply
#7

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)