Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Tuesday, April 16, 2024
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  How to fill a dropdown box with values from multiple tables

phpMyEdit General     How to fill a dropdown box with values from multiple tables
Post new topic   Reply to topic    
 
Sebzap     Joined: 05 Oct 2007   Posts: 5  
Post Posted: 2007-10-05 12:09
Back to top  Reply with quote     

Hello all,

after searching through the forum and the documentation I can't find a solution for doing a join over multiple tables. The solution posted here is not working for the recent version.

Situation: I want to manage the basic function of a library: lend books to people.

The tables I use (with only the important fields to keep it short) are:

tbl_lendings
- id
- book_id

tbl_books
- id
- title
- author_id

tbl_authors
- id
- name

What I want to do is to create a dropdown box in the "add lending" screen where I can select a book. The descritption is supposed to show both the author and the title of the book, e.g. "Simon Singh - The Big Bang".

With the following definition I can show only the book title and the author's ID, but not his name ("1 - The Big Bang").

Code:

$opts['tb'] = 'tbl_lendings';

$opts['fdd']['book_id'] = array(
  'name'     => 'Book',
  'select'   => 'D',
  'options'  => 'AVCPD',
  'sort'     => true
);
$opts['fdd']['book_id']['values']['table']= 'tbl_books';
$opts['fdd']['book_id']['values']['column']= 'ID';
$opts['fdd']['book_id']['values']['description']['columns']['0'] = 'author_id';
$opts['fdd']['book_id']['values']['description']['divs']['0'] = '-';
$opts['fdd']['book_id']['values']['description']['columns']['1'] = 'title';


How can I accomplish what I want to do? Is the magic word "virtual fields"? Or is there another solution?

Thanks in advance for any reply!

Regards
Sebastian

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2007-10-05 12:22
Back to top  Reply with quote     

with current pme i see two solutions:
- create a view author_book
- in pme config something like
$opts['fdd']['dummy']'values2'] = array( 'table'=>'tbl_authors', 'column'=>'id', 'join'=>'tbl_book.author_id = tbl_author.id');

or something similar (create dummy field with all authors in, an in join part limit them to the book), i've never tested it.

btw, each book has just one author ? :)

 
Sebzap     Joined: 05 Oct 2007   Posts: 5  
Post Posted: 2007-10-05 12:27
Back to top  Reply with quote     

Thanks for the quick reply! Actually I'm not managing a library but a more specific application. I thought it's more easy for others to understand the problem if I use a more common example. You are right - the database scheme is not the best... :-)
I will try to get it work and come back to you.

 
Sebzap     Joined: 05 Oct 2007   Posts: 5  
Post Posted: 2007-10-05 13:21
Back to top  Reply with quote     

Sorry, I do not get any step close... I'm thinking about triggers, the php directive, ... My head is stuck.
May you give me a little bit more code?
What do you mean with "create a view author_books"?
Are triggers or the php directive an option?

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2007-10-06 13:28
Back to top  Reply with quote     

on the sql level, create a view (see man create view) that will include all necessary fields in one table/view.

 
Sebzap     Joined: 05 Oct 2007   Posts: 5  
Post Posted: 2007-10-09 12:16
Back to top  Reply with quote     

Okay, I thought you mean a view within PME. I created the view on the MySQL level and it works like a charme. Would have preferred to do this within PME but that is good enough. Thanks Michal!

 
collegefootball     Joined: 09 Mar 2024   Posts: 173  
Post Posted: 2024-04-15 00:30
Back to top  Reply with quote     

Miami Hurricanes Football Jerseys
Ball State Cardinals Apparels
UGA Bulldogs Jerseys
PSU Jerseys
BYU Cougars Football Jerseys
Texas Longhorns Apparels
Lonhorns Apparels
LSU Tigers Apparels
WVU Jerseys
Alabama Jerseys
Oklahoma State Apparels
OSU Buckeyes Jerseys
SMU Mustangs Football Jerseys
Ole Miss Apparels
New Hampshire Wildcats Jerseys
Pitt Panthers Apparels
WKU Football Jerseys
Arizona Wildcats Big 12 Jerseys
Cincinnati Bearcats Football Jerseys
Oklahoma Sooners Apparels
BGSU Falcons Jerseys
OSU Buckeyes Jerseys
Clemson Tigers Apparels
Tennessee Volunteers Apparels
Tulane Green Wave Apparels
Stony Brook Seawolves Jerseys
Sacramento State Hornets Jerseys
UNC Tar Heels Jerseys
Charlotte 49ers Football Jerseys
Alabama Crimson Tide Jerseys
West Virginia Mountaineers Jerseys
Duke Football Apparels
WSU Cougars Jerseys
Nebraska Cornhuskers Football Jerseys
Iowa Hawkeyes Apparels
Colorado Buffaloes Football Jerseys
Cal Bears Football Jerseys
Ole Miss Apparels
Buffaloe Bulls Apparels
Eastern Michigan Eagles Jerseys
UNC Tar Heels Jerseys
Michigan Wolverines Apparels
Alabama State Hornets Jerseys
Georgia Bulldogs Apparels
Wyoming Cowboys Apparels
Utah State Aggies Jerseys
Syracuse Orange Football Jerseys
Toledo Rockets Football Apparels
Houston Cougars Apparels
Iowa Hawkeyes Jerseys
Florida Atlantic Football Jerseys
Montana Grizzlies Apparels
UCLA Big 10 Jerseys
Vanderbilt Commodores Apparels
USC Football Jerseys
Iowa State Jerseys
Arkansas Razbacks Apparels
Georgia Bulldogs Apparels
BYU Cougars Uniforms
UH Cougars Apparels
Rutgers Football Uniforms
Hokies Football Jerseys
ASU Football Jerseys
WSU Cougars Jerseys
Virginia Football Jerseys
Minnesota Golden Gophers Uniforms
UCF Knights Apparels
Auburn Tigers Uniforms
Miami Hurricanes Football Jerseys
Colorado Buffaloes Jerseys
Duke Blue Devils Jerseys
Nebraska Cornhuskers Basketball Jerseys
Nebraska Football Uniforms
Missouri Tigers Apparels
Louisville Football Uniforms
Michigan Wolverines Apparels
Clemson Football Jereys
UCLA Bruins Football Jerseys
Penn State Apparels
TCU Football Uniforms
LSU Tigers Uniforms
Florida State Jerseys
USC Torjans Uniforms
Oregon Ducks Apparels
UCLA Basketball Apparels
Iowa Hawkeyes Jerseys
Kentucky Wildcats Apparels
Indiana Hoosiers Basketball Jerseys
Tennessee Volunteers Jerseys
Stanford University Football Jerseys
Wisconsin Badgers Football Jerseys
Villanova Wildcats Basketball Apparels
Ohio State Buckeyes Jerseys
Texas Aggies Jerseys
Kansas Jayhawks Jerseys
Ole Miss Football Jerseys
Notre Dame Fighting Irish Jerseys
Florida Gators Football Jerseys
Duke Basketball Uniforms
Cal Bears Football Jerseys
NDSU Football Jerseys
WSU Cougars Jerseys
Texas Longhorns Jerseys
Oklahoma Sooners Uniforms
Oklahoma State Jerseys
South Carolina Jerseys
Wake Forest Uniforms
Uconn Jerseys
Mississippi State Football Jerseys
Virginia Cavaliers Basketball Jerseys
Oregon DUcks Football Jerseys
Marshall University Jerseys
Michigan State Spartans Jerseys
Arizona Wildcats Jerseys
Kansas Jayhawks Football Jerseys
Indiana Hoosiers Football Jerseys
Illinois Football Apparels

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy