Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving database column using JSON
    primarykey
    data
    text
    <p>I have a database consist of 4 columns (id-symbol-name-contractnumber). All 4 columns with their data are being displayed on the user interface using JSON.</p> <p>There is a function which is responisble to add new column to the database e.g (countrycode). </p> <p>The coulmn is added successfully to the database BUT not able to show the new added coulmn in the user interface.</p> <p>Below is my code that is displaying the columns. </p> <p>Can you help me?</p> <p>table.php</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /&gt; &lt;script type="text/javascript" src="../../scripts/jquery-1.8.3.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxcore.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxmenu.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxgrid.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxdata.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../scripts/gettheme.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { // prepare the data var theme = getDemoTheme(); var source = { datatype: "json", datafields: [ { name: 'id' }, { name: 'symbol' }, { name: 'name' }, { name: 'contractnumber' } ], url: 'data.php', filter: function() { // update the grid and send a request to the server. $("#jqxgrid").jqxGrid('updatebounddata', 'filter'); }, cache: false }; var dataAdapter = new $.jqx.dataAdapter(source); // initialize jqxGrid $("#jqxgrid").jqxGrid( { source: dataAdapter, width: 670, theme: theme, showfilterrow: true, filterable: true, columns: [ { text: 'id', datafield: 'id', width: 200 }, { text: 'symbol', datafield: 'symbol', width: 200 }, { text: 'name', datafield: 'name', width: 100 }, { text: 'contractnumber', filtertype: 'list', datafield: 'contractnumber' } ] }); }); &lt;/script&gt; &lt;/head&gt; &lt;body class='default'&gt; &lt;div id="jqxgrid"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>data.php</p> <pre><code> &lt;?php #Include the db.php file include('db.php'); #Connect to the database //connection String $connect = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die('Could not connect: ' . mysql_error()); //Select The database $bool = mysql_select_db($mysql_database, $connect); if ($bool === False){ print "can't find $database"; } $query = "SELECT * FROM pricelist"; $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); $orders = array(); // get data and store in a json array while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $orders[] = array( 'id' =&gt; $row['id'], 'symbol' =&gt; $row['symbol'], 'name' =&gt; $row['name'], 'contractnumber' =&gt; $row['contractnumber'] ); } echo json_encode($orders); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload