addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

Re: [php-49] Need a dropdown in handsontable.

From: Andrew
Sent on: Monday, July 25, 2016, 10:14 AM
Hey Ramesh,

Each framework (WordPress vs Laravel vs Zend ) has it's own way of connecting to databases and running queries. Here is a simple way to do it outside of a framework. 

For the following code to work, you'll need to create a couple of define() statements for DSN, DB_USER, DB_PASS

//

class RameshApp {

    /** PDO database connection  */
    protected $dbh;

    public function __construct( PDO $db ) {
        $this->dbh = $db;
    }

    public function getStudentNames() {
        $sql = "SELECT id, first_name, last_name FROM student";

        $sth = $this->dbh->prepare( $sql );
        $sth->execute();

        $result = $sth->fetchAll();

        return $result;
    }
}


$pdo = new PDO( DSN, DB_USER, DB_PASS );

$app = new RameshApp( $pdo );
$names = $app->getStudentNames();

print_r( $names );



#
# Andrew Woods
# Seattle, WA
# http://andrewwoods.net
#
#    "With each sunrise, we start anew"
#


On Mon, Jul 25, 2016 at 8:31 AM, Ramesh K <[address removed]> wrote:

how can i show a dropdown in handsontable with values already stored in database.

for example, am having a certain students name in db. now want to show all student name in dropdown which is saved in db using class.

please help...am just a beginner





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Meetup on behalf of Ramesh K from Seattle PHP User Group.
To report this message or block the sender, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

People in this
group are also in: