Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Adding a dropdown list from another table.

phpMyEdit General     Adding a dropdown list from another table.
Odoslať novú tému   Odpovedať na tému    
 
geohix     Založený: 12.10.2009   Príspevky: 1  
Príspevok Zaslal: 2009-10-12 19:26
Návrat hore  Odpovedať s citátom     

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     Založený: 16.06.2009   Príspevky: 3  
Príspevok Zaslal: 2009-10-16 18:52
Návrat hore  Odpovedať s citátom     

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     Založený: 25.10.2009   Príspevky: 1  
Príspevok Zaslal: 2009-10-25 19:38
Návrat hore  Odpovedať s citátom     

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

 
efreedom     Založený: 12.01.2010   Príspevky: 1  
Príspevok Zaslal: 2010-01-12 19:57
Návrat hore  Odpovedať s citátom     

Kód:
$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     Založený: 14.04.2011   Príspevky: 0  
Príspevok Zaslal: 2011-04-15 00:03
Návrat hore  Odpovedať s citátom     

efreedom Napísal:
Kód:
$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



 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov