Page 1 of 1

Filtrating data from db in livecode

Posted: Sat Oct 19, 2013 6:45 pm
by totalnoob
Hi im creating app with movie mysql database and i need somehow filtrate movies etc when someone choose Drama 90> with Morgan Freeman it will show that movies.I know how to connect to mysql with livecode retrive data and stuff but really dont know how to make it work

Thanks

Re: Filtrating data from db in livecode

Posted: Sat Oct 19, 2013 8:52 pm
by bangkok
Trials and errors. Plus guidances on the web. That's the only way.

Basically you need to create a SELECT query, with the proper way -that is the SQL way- the "filters" you're talking about.

But it depends a lot of your columns structure.

-Genre : will it be a text column ? Or an integer that points to another table (join) ?

-Time : year only ? Or a precise date ?

-Actors : only the leading role ? A list ?

You have a gazillons of super web sites out there that teach SQL.

When you have a clearer view of how it works, and how you should organize your tables and your columns... then we can help you with some specific LiveCode question.

Re: Filtrating data from db in livecode

Posted: Sat Oct 19, 2013 11:03 pm
by totalnoob
i created this http://bayimg.com/labNDaaFb which is working i just need somehow connect buttons to it that will print out movies you know ?

Re: Filtrating data from db in livecode

Posted: Sun Oct 20, 2013 3:00 am
by icouto
totalnoob wrote:i created this http://bayimg.com/labNDaaFb which is working i just need somehow connect buttons to it that will print out movies you know ?
It is a bit difficult to understand exactly what you're trying to do. The screenshot of your app's interface is nice, but it doesn't help much.

From what I see, you have a list of movie TITLES that you present to the user. Underneath that list you have placed a Search field, with 2 buttons: Search by Actor, and Search by Genre. I'm guessing, that you want the user to type something, and press one of the buttons. Depending on the button pressed, you would then perform the proper search - ie, give the user a list of films based either on the genre or the actor name they entered. Is that correct?

If so, in order for us to tell you how to search your database, we have to know how your database is setup. Do you have different tables for 'Movies', 'Actors' and 'Genres'? What fields do you have in each of these tables? How are the records from one table related to the other? We cannot give you guidance without the required information...

Re: Filtrating data from db in livecode

Posted: Sun Oct 20, 2013 10:24 am
by totalnoob
i want make fuction called ,,movie picker" :D there people will choose http://bayimg.com/JAbHCAAFc http://bayimg.com/jaBHFaAfC you know ? and it will show them movies by choosing parameters of the movie :D http://bayimg.com/jabhGAaFC

Re: Filtrating data from db in livecode

Posted: Sun Oct 20, 2013 11:44 am
by Klaus
Hi totalnoob (about time to leave this state! 8) ),

I'm afraid you cannot avoid to learn some SQL for your project!
This one got me started with SQL: http://www.w3schools.com/sql/default.asp


Best

Klaus

Re: Filtrating data from db in livecode

Posted: Sun Oct 20, 2013 1:53 pm
by totalnoob
i have idea
its there a way how to move data from datagrid to another datagrid on another card i have it grouped but its not working. there will be data grid on every card (invisible) and it will filtrate by movies by choosing categories and stuff and at the end it will show only that movies what you think ?
btw my code looks like

Code: Select all

on mouseUp
   global gConnectionID
get revDataFromQuery(tab, return, gConnectionID, "SELECT * FROM movies WHERE Genre LIKE '%" & Drama & "%'")
set the dgText of group "datagrid 1" to it
      go to next card
end mouseUp

Re: Filtrating data from db in livecode

Posted: Mon Oct 21, 2013 11:54 am
by Klaus
I think that using (hidden) datagrids for this is an unneccessary and ineffective hack with too much overhead 8)

No idea why you refuse to learn a BIT about SQL, waht you have in mind is a snap with SQL! :D