jQWidgets Forums
Forum Replies Created
Viewing 1 post (of 1 total)
-
Author
-
November 25, 2019 at 7:44 pm in reply to: JQXGRID not showing any data from mySQL connection JQXGRID not showing any data from mySQL connection #107449
Hello. I added the missing code from the demo, but it still isn’t working. Any advice will be appreciated. This is my first attempt to use JQwidgets. My updated jsp file is below.
<!DOCTYPE html> <html lang='en'> <head> <meta charset="ISO-8859-1"> <title>titanic</title> <link type="text/css" rel="Stylesheet" href="css/jqx.base.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jqxcore.js"></script> <script type="text/javascript" src="js/jqxdata.js"></script> <script type="text/javascript" src="js/jqxbuttons.js"></script> <script type="text/javascript" src="js/jqxscrollbar.js"></script> <script type="text/javascript" src="js/jqxmenu.js"></script> <script type="text/javascript" src="js/jqxcheckbox.js"></script> <script type="text/javascript" src="js/jqxlistbox.js"></script> <script type="text/javascript" src="js/jqxdropdownlist.js"></script> <script type="text/javascript" src="js/jqxgrid.js"></script> <script type="text/javascript" src="js/jqxgrid.selection.js"></script> <script type="text/javascript"> $(document).ready(function () { var source = { datatype: "json", datafields: [{ name: 'PassengerID'}, {name: 'Survived'}, {name: 'Sex'}, {name: 'Age'}, {name: 'Fare'} ], id: 'PassengerID', url: 'select-data.jsp', async: true }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid({ width: 740, autoheight: true, source: dataAdapter, columns: [{ text: 'PassengerID', datafield: 'PassengerID', width: 100 }, { text: 'Survived', datafield: 'Survived', width: 100 }, { text: 'Sex', datafield: 'Sex', width: 180 }, { text: 'Age', datafield: 'Age', width: 180 }, { text: 'Fare', datafield: 'Fare', width: 180 }] }); }); </script> </head> <body> <div id="jqxgrid"></div> </body> </html> <!--grid_data.php #Include the connect.php file include ('connect.php'); // Connect to the database // connection String $mysqli = new mysqli($//localhost:3306, $root, $EZOPS, $titanicDB); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } // get data and store in a json array $from = 0; $to = 30; $query = "SELECT PassengerID, Survived, Sex, Age, Fare FROM titanicD"; // LIMIT ?,?"; $result = $mysqli->prepare($query); $result->bind_param('ii', $from, $to); $result->execute(); /* bind result variables */ $result->bind_result($PassengerID, $Survived, $Sex, $Age, $Fare); /* fetch values */ while ($result->fetch()) { $orders[] = array( 'PassengerID' => $PassengerID, 'Survived' => $Survived, 'Sex' => $Sex, 'Age' => $Age, 'Fare' => $Fare ); } echo json_encode($orders); /* close statement */ $result->close(); /* close connection */ $mysqli->close(); -->
-
AuthorPosts
Viewing 1 post (of 1 total)