Getting record from second table

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 30, 2009   (RSS)

Re: [eduran582] Getting record from second table

By Dave - January 30, 2009

Hi Eric,

So it's returning all the records from 'registration' but you only want some right?

Which records do you want? As in, do you want record where the registration field 'classNum' equals the value in $evocRecord['num']? If so, there where for that would be as follows:

...
'tableName' => 'registration',
'where' => " classNum = '" .mysql_real_escape_string($evocRecord['num']). "' ",
...

Basically, the first step is to figure out the rule you want to filter on. For example "I want to show records from this table where field "x" equals the value of field "y" from this other record I've already loaded. Then write that as a where.

I hope that helps. Let me know how it goes.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Getting record from second table

Hi Dave,

Your example was great! I changed it a bit but the result was just what I wanted. It was all there in the 'where' syntax. In your example:

[font "Verdana"]'where' => " classNum = '" .mysql_real_escape_string($evocRecord['num']). "' ",

[font "Verdana"]I used:

[font "Verdana"]'where' => " num[/#800000] = '" .mysql_real_escape_string($evocRecord['list_record'[/#800000]]). "' ",

What I was trying to do, which I couldn't have figured out without your help, was to say "I want the record 'num' from table 'registration' (that has all the dates) that is indicated in the variable 'list_record' in the 'evoc' table for use in the record I'm displaying (to show the dates).

Thanks for again for the outstanding support! [;)]

Eric

Re: [eduran582] Getting record from second table

By Dave - January 30, 2009

Great! Glad to hear it's working. Thanks for posting back to let us know. :)
Dave Edis - Senior Developer
interactivetools.com