Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Adding a dropdown list from another table.

phpMyEdit General     Adding a dropdown list from another table.
Post new topic   Reply to topic    
 
geohix     Joined: 12 Oct 2009   Posts: 1  
Post Posted: 2009-10-12 19:26
Back to top  Reply with quote     

I am trying to add a drop down list from another table. PlayerTeamID = TeamID in a different table. However the users editing this have no clue that PlayerTeamID '3' = 12 National Team. I would like to display the "TeamName" from the Teams table. When the user edits the record they choose the appropriate team and it write the ID into the database. Here is what I have for displaying the PlayerTeamID.

$opts['fdd']['PlayerTeamID'] = array(
'name' => 'PlayerTeamID',
'select' => 'T',
'maxlen' => 11,
'sort' => true
);

Any assistacne would be greatly appreciated.

 
Lonestar     Joined: 16 Jun 2009   Posts: 3  
Post Posted: 2009-10-16 18:52
Back to top  Reply with quote     

I used this as a base http://opensource.platon.sk/forum/projects/viewtopic.php?t=457891&highlight=dropdown .
---------------------------------------
My code is:
$opts['fdd']['Agency'] = array(
'name' => 'Agency',
'values' => array(
'table' => 'categories',
'column' => 'category'
)
);
----------------------------------------
This made a dropdown list in a table called bills and a field called Agency with a title of Agency from a table named Categories and a field called category
------------------------------------------
I had been messing with this for a few days before figuring it out. Really simple when you get to it.

 
albatross77     Joined: 25 Oct 2009   Posts: 1  
Post Posted: 2009-10-25 19:38
Back to top  Reply with quote     

I've gotten this to work. But how do you make the dropdown display options from a directory?

 
efreedom     Joined: 12 Jan 2010   Posts: 1  
Post Posted: 2010-01-12 19:57
Back to top  Reply with quote     

Code:
$dir = "/html/public_html/img/";
$dh = opendir($dir);
$files = array();
while ($file = readdir($dh)){
  # Only track files then end in "jpg"
  if (preg_match("/jpg$/", $file)){
    array_push($files, $file);
  }
}
# Arrange file names alphabetically
sort($files);

$opts['fdd']['leftPic'] = array(
  'name'     => 'LeftPic',
  'select'   => 'D',
  'maxlen'   => 35,
  'sort'     => true,
);

$opts['fdd']['leftPic']['values'] = $files;


 
ghecken     Joined: 14 Apr 2011   Posts: 0  
Post Posted: 2011-04-15 00:03
Back to top  Reply with quote     

efreedom wrote:
Code:
$dir = "/html/public_html/img/";
$dh = opendir($dir);
$files = array();
while ($file = readdir($dh)){
//  Only track files then end in "jpg"
  if (preg_match("/jpg$/", $file)){
    array_push($files, $file);
  }
}
// Arrange file names alphabetically
sort($files);

$opts['fdd']['leftPic'] = array(
  'name'     => 'LeftPic',
  'select'   => 'D',
  'maxlen'   => 35,
  'sort'     => true
);

$opts['fdd']['leftPic']['values'] = $files;


Great work, I spent some time trying to achive what your example does.
I found a bug in your code:
"," behind "true" breaks the script.
And shouldn't remarks in php begin with "//"?

Regards,
Guido



 
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