Jump to content

html table with data from 2 sources

Go to solution Solved by requinix,

Recommended Posts


I have 2 database tables:

1) products which contain 3 columns: id, description and unit

2) units which contains 2 columns: id and description

I need to pupulate html table with data from 2 database tables.this is the structure:

id, description, unit, unit_description (the first 3 columns come from table 1 and the fourth column from table 2

I know hot to pupulate the table according to the 3 columns: (the remarks are for the 4th column that i dont know how to call). I want this column to get the description of the unit in the row from the second table in the database - using the get_unit_desc in the GlDbOra.php file (Not by making a join in the select) 

How can I do that? I'll be happy for any help


        <meta charset="UTF-8">
        <script type="text/javascript" src="../../Bundles/php-ajax/jquery-3.5.1.js"></script>  
        <script src="../Bundles/bootstrap-4.5.0-dist/js/bootstrap.min.js"></script> 
        <link href="../Bundles/bootstrap-4.5.0-dist/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> 
        <link href="../xxx/css/global_style.css" type="text/css" rel="stylesheet" madia="all"/> 
        <div class="container">
            <div class="row">
                <div class="panel  panel-primary filterable">
                   <div class="panel-heading">
                        <h3 class="panel-title">Products</h3>
                        <div class="pull-right">
                            <button class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button>
                    <form id="data_form" name="datatable_form" method="POST">
                        <div class="table-repsonsive">
                            <table class="table table-bordered" id="tab_logic">                                        
                                    <tr class="filters" id="table_header_2_btn">
                                        <th width="12%"><input type="text" class="form-control" name="Id[]" value="" placeholder="Id" disabled /></th>
                                        <th width="30%"><input type="text" class="form-control" name="DESCRIPTION[]" value="" placeholder="Description" disabled /></th>
                                        <th width="12%"><input type="text" class="form-control" name="UNIT[]" value="" placeholder="Unit"  disabled /></th>
<!--                                        <th width="30%"><input type="text" class="form-control" name="UNIT_DESCRIPTION[]" value="" placeholder="Description" disabled /></th> -->
                                        <th width="12%"></th>
                                        foreach ($cursor as $cursorCurrentRow) 
                                            echo '<tr class="form-group">';
                                            echo "<td width=".'"12%"><input type="text" name="ID[]" value="'.htmlspecialchars($cursorCurrentRow['ID'], ENT_QUOTES).'" disabled style="border:none;"></td>';
                                            echo "<td width=".'"30%"><input type="text" name="DESCRIPTION[]" value="'.htmlspecialchars($cursorCurrentRow['DESCRIPTION'], ENT_QUOTES).'" disabled style="border:none;"></td>';
                                            echo "<td width=".'"12%"><input type="text" name="UNIT[]" value="'.htmlspecialchars($cursorCurrentRow['UNIT'], ENT_QUOTES).'" disabled style="border:none;"></td>';
//                                            echo "<td width=".'"30%"><input type="text" name="UNIT_DESCRIPTION[]" value="'.htmlspecialchars($cursorCurrentRow['DESCRIPTION'], ENT_QUOTES).'" disabled style="border:none;"></td>';
                                            echo "<td width=".'"12%">'
                                                    . '<a class='.'"add" title='.'"Add" data-toggle='.'"tooltip"><i class='.'"material-icons">&#xE03B;</i></a>'
                                                    . '<a class='.'"edit" title='.'"Edit" data-toggle='.'"tooltip"><i class='.'"material-icons">&#xE254;</i></a>'
                                                    . '<a class='.'"delete" title='.'"Delete" data-toggle='.'"tooltip"><i class='.'"material-icons">&#xE872;</i></a>'
                                                    . '</td>';
                                            echo "</tr>\n";
                <button class="regular_button" id="add-new"><span class="glyphicon glyphicon-plus"></span> Add Rows</button>
                <button class="regular_button" id="save_rows"><span class="glyphicon glyphicon-floppy-save"></span> Save</button>


    class DBOracle 
        private static $instance = null;

        public static function getInstance() 
            if (!self::$instance instanceof self) 
                self::$instance = new self;
            return self::$instance;
        public function __clone() 
            trigger_error('Clone is not allowed.', E_USER_ERROR);

        public function __wakeup() 
            trigger_error('Deserializing is not allowed.', E_USER_ERROR);

        public function __construct () 
            $databaseConfig = include 'config.php';
            $this -> OracleUser = $OracleUser;
            $this -> OraclePwd = $OraclePwd;
            $this -> OracleDB = $OracleDB;
            $this->con = oci_connect($this->OracleUser, $this->OraclePwd, $this->OracleDB);
            if (!$this->con) {
                $e = oci_error();
                trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);

        public function get_products() 
            $query = "begin get_products(:cursor); end;";
            $stid = oci_parse($this->con, $query);
            $p_cursor = oci_new_cursor($this->con);
            oci_bind_by_name($stid, ':cursor', $p_cursor, -1, OCI_B_CURSOR);
            oci_execute($p_cursor, OCI_DEFAULT);
            oci_fetch_all($p_cursor, $cursor, null, null, OCI_FETCHSTATEMENT_BY_ROW);
            return  $cursor;

        public function get_unit_desc($unitid) 
            $query = "begin :unit_desc_bv := get_unit_desc(:id_bv); end;";
            $stid = oci_parse($this->con, $query);
            oci_bind_by_name($stid, ':id_bv', $unitid);
            oci_bind_by_name($stid, ':unit_desc_bv', $unit_desc,30);
            return $unit_desc;


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.