• [MOD] Dropdown options for custom database fields 4 0 5 1
Currently:  

Author Topic: [MOD] Dropdown options for custom database fields  (Read 199159 times)

0 Members and 1 Guest are viewing this topic.

Offline live@ct

  • Sr. Member
  • ****
  • Posts: 348
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #105 on: June 24, 2009, 09:50:08 AM »
For the vetsion 1.7.7 how can I make to  use the dropdown for image fields and user_field, the user_country, I have both in the user and images tables, but I dont know if I can use the same array for both because when some user try to register the user_country_dropdown works, but in the member_upload_form it not show the country_dropdown

I need to make a separate array or why it not showing in the upload form
Existen 10 tipos de personas, los que entienden el codigo binario y los que no.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #106 on: November 23, 2009, 02:04:18 PM »
Hello,

I am trying to get some information from the database using the Dropdown option for custom database fields. It works almost, but because I am not a PHP programmer I need some support from you guys.

In the db_fields_definitions.php I use the following code:

Code: [Select]
$sql = "SELECT zu_players_name
             FROM ".ZU_PLAYERS_TABLE."
";
             $result = $site_db->query($sql);
while ($zu_players_row = $site_db->fetch_array($result)) {
     $zu_players_name = $zu_players_row['zu_players_name'];
         
}


And then I used $zu_players_name in this code:

Code: [Select]
$additional_zu_games_fields['zu_games__goals'] = array($lang['zu_games__goals'], "dropdown", 0, array($zu_players_name), 0, 0, 0, 0);

Almost there. The results is only the last name in the list. (Only 1 name)

I need some help to get all the names of the list.

Your help is appreciated,

Cruxy

Rembrandt

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #107 on: November 23, 2009, 08:34:41 PM »
...
Almost there. The results is only the last name in the list. (Only 1 name)

I need some help to get all the names of the list....

test it:
$zu_players_name .= $zu_players_row['zu_players_name'];

mfg Andi

Offline V@nо

  • Addicted member
  • ******
  • Posts: 1.223
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #108 on: November 23, 2009, 10:21:48 PM »
actually, you need save them into an array:
$zu_players_name[] = $zu_players_row['zu_players_name'];
Your first three "must do" before you ask a question:
If I asked you to PM me, I meant PM to my primary account, this account doesn't accept PMs.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #109 on: November 23, 2009, 10:25:46 PM »
Thanks Rambrand & V@no.

The 2 solutions did not work for me. I used this one:

Code: [Select]
$zu_players_name[] = current($zu_players_row);
It works fine.

Thanks anyway for your help.
Cruxy

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #110 on: December 01, 2009, 09:01:50 PM »
Hello,

I have a question:

This is my code to get information from the database using the dropdown box for custom db field:

Code: [Select]
$sql = "SELECT zu_games_name
             FROM ".ZU_GAMES_TABLE."
";
             $result = mysql_query($sql);
$zu_games_name = array();
while ($zu_games_row = $site_db->fetch_array($result)) {
$zu_games_name[] = current($zu_games_row);
             $additional_zu_goals_fields['zu_goals_name'] = array($lang['zu_goals_name'], "dropdown", 0, $zu_games_name, 0, 0, 0, 0);
 }

My question is:

How can I get the ------------------ in the begining of each dropdown. I tried everything, but without success. Any please?

Many thanks in advance,
Cruxy

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #111 on: December 02, 2009, 02:34:11 AM »
	
	
	
 
$zu_games_name = array("----------------------");
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #112 on: December 02, 2009, 05:32:16 AM »
I did not thought about this solution. It works perfect. Thankt a lot.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #113 on: February 26, 2010, 08:28:58 PM »
-> Google
The drop-down boxes are not stored in the "Edit Images". With each call you have to reset them. In the ACP, but the fields are saved and are on the option you have chosen as the last!

Die Dropdownfelder werden im Bereich "Edit Images" nicht gespeichert. Bei jedem Aufruf muss man diese neu setzen. Im ACP werden die Felder aber gespeichert und stehen auf der Option die man als letztes gewählt hat!
« Last Edit: February 27, 2010, 12:10:52 PM by Sumale.nin »

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #114 on: February 28, 2010, 12:02:58 PM »
Ich weis nicht woran es liegt!
Aber im Editmages stehen die Dropdowns nicht auf der Option die man gewählt hatte, aber im ACP ist das so!

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: [MOD] Dropdown options for custom database fields
« Reply #115 on: May 02, 2010, 07:17:42 PM »
Der Code von der Version 1.6.7 ist komplett 1.7.7 tauglich, kann im ersten Posting editiert werden.

LG
Danke Harald




Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #116 on: June 18, 2010, 10:43:49 AM »
Hi,

After trying without any progress, I want to ask you guys about this issue.

I am using this code to get the name of the users (He is working fine):

Code: [Select]
<?php $sql "SELECT user_name
             FROM "
.USERS_TABLE."
 ORDER BY user_name ASC
 "
;
             
$result mysql_query($sql);
 $user_name = array("----------------------");
 while ($user_row $site_db->fetch_array($result)) {
 $user_name $user_name;
 $user_name[] = current($user_row);
             
$additional_test_fields['test_player'] = array($lang['test_player'], "dropdown"0$user_name0000);
 }
?>

The results is:

ADMIN
user1
user2
user3


Now I want to get also the user_id after the name of the user. Something like:

ADMIN (id=9)
user1 (id=1)
user2 (id=2)
user3 (id=3)



Could you help please?

Many thanks in advance,
Cruxy
« Last Edit: June 18, 2010, 11:45:03 AM by cruxy »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #117 on: June 18, 2010, 02:51:30 PM »
<?php
$sql 
"SELECT " get_user_table_field("""user_name") . get_user_table_field(",""user_id") . "
        FROM "
.USERS_TABLE."
        WHERE " 
get_user_table_field("""user_level") . " > " GUEST ."
        ORDER BY " 
get_user_table_field("""user_name") . " ASC";
$result $site_db->query($sql);
$user_name = array("----------------------");
while (
$user_row $site_db->fetch_array($result))
{
  
$user_name[] = $user_row[$user_table_fields['user_name']] . " (ID=" $user_row[$user_table_fields['user_id']] . ")";
}
$additional_test_fields['test_player'] = array($lang['test_player'], "dropdown"0$user_name0000);
?>


I don't know what is your code that receives the value from the dropdown, but I'd suggest use multidimention array instead:

<?php
$sql 
"SELECT " get_user_table_field("""user_name") . get_user_table_field(",""user_id") . "
        FROM "
.USERS_TABLE."
        WHERE " 
get_user_table_field("""user_level") . " > " GUEST ."
        ORDER BY " 
get_user_table_field("""user_name") . " ASC";
$result $site_db->query($sql);
$user_name = array("----------------------");
while (
$user_row $site_db->fetch_array($result))
{
  
$user_name[$user_row[$user_table_fields['user_id']]] = $user_row[$user_table_fields['user_name']] . " (id=" $user_row[$user_table_fields['user_id']] . ")";
}
$additional_test_fields['test_player'] = array($lang['test_player'], "dropdown"0$user_name1000);
?>


Dropdown will return user_id
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #118 on: June 18, 2010, 09:31:51 PM »
Thanks V@no for the solution. It's works perfect, but I got another problem.

I want to show this format in the dropdown: user1 (ID= 1), but I want to save only the user_name in the database (user1).

Is that possible?


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #119 on: June 19, 2010, 01:53:01 AM »
use my second code and then replace
  $user_name[$user_row[$user_table_fields['user_id']]] = $user_row[$user_table_fields['user_name']] . " (id=" $user_row[$user_table_fields['user_id']] . ")";


with

  $user_name[$user_row[$user_table_fields['user_name']]] = $user_row[$user_table_fields['user_name']] . " (id=" $user_row[$user_table_fields['user_id']] . ")";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)