Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Help with Dropdown list (http://www.mysidiaadoptables.com/forum/showthread.php?t=5365)

Abronsyth 02-11-2017 11:36 AM

Help with Dropdown list
 
Alrighty, so I am attempting to put together a dropdown list that will display a user's pets that are "no" for use alternates and level 4...I'm having issues with it.

I am just getting a blank drop-down list. Right now I'm just trying to list all of the user's pets.

Here's the code I'm attempting....

PHP Code:

$stmt $mysidia->db->select("owned_adoptables", array("name"), "owner = '{$mysidia->input->get("user")}'");
$name $stmt->fetchColumn();
$formExample = new Form("exampleform""page_to_send_to_here""post");
$exampleDropdown = new DropdownList("solarList");
$exampleDropdown->add(new Option("{$name}""{$name}"));
$formExample->add($exampleDropdown);
$formExample->add(new Button("Click Me""submit""submit"));
$document->add($formExample); 

This is my first time trying to work with dropdown lists in Mysidia, so I am very lost. If anyone could help I'd really appreciate it.

Dinocanid 02-11-2017 12:03 PM

To display all of a user's pets in a dropdown, there's this code
PHP Code:

$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}'"); 

You can narrow down which adoptables are available in the dropdown, in your case by level and alternates, with something like this:
PHP Code:

$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND level >= '4' AND usealternates = 'no'"); 

It would also select adoptables who have a level higher than 4, since it uses ">=", but you could change it to just "=" if you only wanted level 4 pets to appear.

Abronsyth 02-11-2017 01:13 PM

Thank you!

But I am still not sure how to actually get it to show that data in the drop down as options :/

By this I mean I'm not sure what to put here;
PHP Code:

$exampleDropdown->add(new Option("pet name?""aid?")); 


Dinocanid 02-11-2017 01:49 PM

Maybe this?:
PHP Code:

$options $mysidia->db->fetchList($stmt);
$exampleDropdown->fill($options); 

I'm going off of this here, maybe it can help?

Abronsyth 02-11-2017 04:42 PM

Thank you for the link, that is helpful.

Hello!!
It is working :D

Thank you for all of your help, Dinocanid <3


All times are GMT -5. The time now is 05:06 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.