Random question time!

Forum
Last Post
Threads / Messages

Infernette

CODE CODE CODE CODE CODE
Member
Joined
Jan 29, 2013
Messages
164
Points
0
Location
Where I live? I live home.
Mysidian Dollar
15,625
How do you get the name and the id of the creature to show in a drop down list? I can get one or the other to show, but not both. I used to know this but now I seemed to have forgot- It would be nice to know how to do it again, and even how to get it to show images would be awesome!
 
Image I don't know if it's possible, but to add the code next to the name I don't really remember how I did it, but I believe I just went to the dropdown list creation and instead of sending just the name i send the code concatenated with the name, like:

$nameFinal = $name .= '( ' .= $code .= ')'

or something alike


edit:

I have this for females in the breeding thing

PHP:
$index = 0;
			foreach($femaleNames as $namesF){
					//echo $femaleIDsarray[$index];
					$equals = " (";
					$equals2 = ")";
					$nameAndID = $namesF .= $equals .= $femaleIDsarray[$index] .= $equals2;
					//echo $nameAndID;
					
					//echo $femaleIDsarray[$index];
					$female->add(new Option($nameAndID, $femaleIDsarray[$index]));
					$index++;
			}
 
Last edited:
I can't seem to get it to work, I get this :
Adopt/Price:Cannot fill option objects inside this dropdownlist
As an error, code:
PHP:
		$ids = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' AND bred != 'comp' AND attached = 'no' and currentlevel > 6 and selling = 'no'")->fetchAll(PDO::FETCH_COLUMN);	
	    $names1 = $mysidia->db->select("owned_adoptables", array("name"), "owner = '{$mysidia->user->username}' AND bred != 'comp' AND attached = 'no' and currentlevel > 6 and selling = 'no'")->fetchAll(PDO::FETCH_COLUMN);

$index = 0; 
            foreach($names1 as $names){ 
                    $equals = " ("; 
                    $equals2 = ")"; 
                    $nameFinal = $names .= $equals .= $ids[$index] .= $equals2; 
                     
                    $index++; 
            }  
        $adoptable->fill($nameFinal, $ids);
		
		$chooseFrom->add($adoptable);
 
I see, because you are using the fill function. In mine I add the options one by one to the dropdown list (called 'female'), so the left side is the field name and the right side the value. Try it like that?
 
I changed it to fill, but now it only shows one of the adoptables.

Updated code:
PHP:
		$ids = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' AND bred != 'comp' AND attached = 'no' and currentlevel > 6 and selling = 'no'")->fetchAll(PDO::FETCH_COLUMN);	
	    $names1 = $mysidia->db->select("owned_adoptables", array("name"), "owner = '{$mysidia->user->username}' AND bred != 'comp' AND attached = 'no' and currentlevel > 6 and selling = 'no'")->fetchAll(PDO::FETCH_COLUMN);

$index = 0; 
            foreach($names1 as $names){ 
                    $equals = " ("; 
                    $equals2 = ")"; 
                    $nameFinal = $names .= $equals .= $ids[$index] .= $equals2; 
                     
                    $index++; 
            }  
        $adoptable->add(new Option($nameFinal, $ids[$index]));
		
		$chooseFrom->add($adoptable);
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,132
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top