function GetcolumnValue($table, $Forgien_Key_Display_Field)
{
    $coulmtype = GetCoulmsInfo($table);
    $primryname = $coulmtype['FieldsName'][0];
    $page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
    if ($page <= 0) {
        $page = 1;
    }
    $per_page = 10;
    // Set how many records do you want to display per page.
    $startpoint = $page * $per_page - $per_page;
    $statement = "`{$table}` ORDER BY `{$primryname}` DESC";
    // Change `records` according to your table name.
    $columvalue = QueryResult("SELECT * FROM {$statement} LIMIT {$startpoint} , {$per_page}");
    $counter = 0;
    $itreation_FK = 0;
    $limtbuttonrepeat = 0;
    //get config info
    $confObj = CheckconfigInfo();
    while ($rowvalue = mysql_fetch_row($columvalue)) {
        echo "<form method='POST' action='authentication/deletequery.php' data-form='true' id='myform_{$counter}'><tr>";
        //we check the length to make it fit with the table responsive
        //append the radio button
        echo "<td ><span id='hash'>#</span><input type='radio' name='showrelatedinfo' value='" . $rowvalue[0] . "' style='display:none;margin-top: -2px;opacity: 1;margin-left: 0px;position: inherit;'></td>";
        if (count($rowvalue) < 8) {
            for ($i = 0; $i < count($rowvalue); $i++) {
                //get primry key for the fields less than 8
                $prima = mysql_get_foregin_key($table, $coulmtype['FieldsName'][$i]);
                if ($prima != '') {
                    //get FK tablename and primary key for the forgien key and the display name if exsist and its value
                    $FK = GetForeginKey_TableName($table, $prima);
                    $Tablename_FK = substr($FK[$prima], 0, strpos($FK[$prima], '.'));
                    // add the button to get all info for this primary key from the related table
                    @($fktables = GetForgienTablename_ForSpecific_Tablename($table));
                    @($fktablesname = substr($fktables[$limtbuttonrepeat], 0, strpos($fktables[$limtbuttonrepeat], '.')));
                    @($fkidname = end(explode(".", $fktables[$limtbuttonrepeat])));
                    if ($limtbuttonrepeat < count($fktables) && $fktablesname != '') {
                        echo "<a id='displayrelatedrecords' onclick=\"window.open('authentication/displayrelatedinfo.php?tablename={$table}&relatedinfo={$fktablesname}&fkfieldname={$fkidname}&relatedid={$rowvalue['0']}&true','Display Related Info','scrollbars=1,resizable=1,width=1200,height=640')\" style=\"cursor: pointer;margin-bottom:10px;margin-right:10px;display:none\" class='btn btn-info'>Display " . " " . ucfirst($fktablesname) . "</a> ";
                    }
                    $limtbuttonrepeat++;
                    $PK_Name_For_FK = end(explode(".", $FK[$prima]));
                    $FKNAME = $coulmtype['FieldsName'][$i];
                    $PK_Value_For_FK = $rowvalue[$i];
                    if (!empty($Forgien_Key_Display_Field)) {
                        if (array_key_exists($Tablename_FK, $Forgien_Key_Display_Field)) {
                            $FK_Field_Display = $Forgien_Key_Display_Field[$Tablename_FK];
                            @($FK_Query = QueryResult("SELECT * FROM {$Tablename_FK}  WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' "));
                            while (@($FKRow = mysql_fetch_array(@$FK_Query))) {
                                echo "<td>" . $FKRow[$FK_Field_Display] . "</td>";
                            }
                            echo "<input  type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" display_name=\"{$FK_Field_Display}\" value=\"{$Tablename_FK}\">";
                        } else {
                            $FK_Query = QueryResult("SELECT * FROM {$Tablename_FK}  WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' ");
                            while ($FKRow = mysql_fetch_array($FK_Query)) {
                                echo "<td>" . substr($FKRow[0], 0, 60) . "</td>";
                            }
                            echo "<input  type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\"  value=\"{$Tablename_FK}\">";
                        }
                        //end of array has no value for this tablename
                    } else {
                        $FK_Query = QueryResult("SELECT * FROM {$Tablename_FK}  WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' ");
                        while ($FKRow = mysql_fetch_array($FK_Query)) {
                            echo "<td>" . substr($FKRow[0], 0, 60) . "</td>";
                        }
                        echo "<input  type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\"  value=\"{$Tablename_FK}\">";
                    }
                } else {
                    //prepare the variables for youtube and viedo and images
                    if (count($confObj) > 0) {
                        if ($confObj['fieldname_image'] != '') {
                            $images = $confObj['fieldname_image'];
                        } else {
                            $images = 'Image';
                        }
                        if ($confObj['youtubefieldname'] != '') {
                            $youtube = $confObj['youtubefieldname'];
                        } else {
                            $youtube = 'YouTube';
                        }
                        if ($confObj['viedofieldname'] != '') {
                            $viedo = $confObj['viedofieldname'];
                        } else {
                            $viedo = 'Video';
                        }
                    } else {
                        $youtube = 'YouTube';
                        $viedo = 'Video';
                        $images = 'Image';
                    }
                    //check for youtube
                    if (preg_match('/' . $youtube . '/', $coulmtype['FieldsName'][$i])) {
                        if (@$rowvalue[$i] != '') {
                            echo "<td><iframe src='{$rowvalue[$i]}' width='130' height='100' frameborder='0' scrolling='no' allowfullscreen></iframe></td>";
                        } else {
                            echo "<td><img src='images/youtube.png' style='width:130px;height:80px;border-radius: 10px;'/></td>";
                        }
                    } else {
                        if (preg_match('/' . $viedo . '/', $coulmtype['FieldsName'][$i])) {
                            if (@$rowvalue[$i] != '') {
                                echo "<td><video width='320' height='240' controls><source src='{$rowvalue[$i]}' type='video/mp4'></video>  </td>";
                            } else {
                                echo "<td><img src='images/video.png' style='width:130px;height:80px;border-radius: 10px;'/></td>";
                            }
                        } else {
                            if (preg_match('/' . $images . '/', $coulmtype['FieldsName'][$i]) && $coulmtype['OrginalFieldType'][$i] != "blob" && $coulmtype['FieldType'][$i] != "text") {
                                //same code for the blob type but we check for the name incase the type is not blob
                                if ($rowvalue[$i] == '') {
                                    echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                } else {
                                    echo "<td><img src='authentication/uploads/{$rowvalue[$i]}' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                }
                            } else {
                                if ($coulmtype['OrginalFieldType'][$i] == "blob" && $coulmtype['FieldType'][$i] != "text") {
                                    if ($rowvalue[$i] == '') {
                                        echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                    } else {
                                        echo "<td><img src='data:image/jpeg;base64," . base64_encode($rowvalue[$i]) . "' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                    }
                                } else {
                                    echo "<td>" . substr($rowvalue[$i], 0, 40) . "</td>";
                                }
                            }
                        }
                    }
                }
                //end of primary key
                // add the edit and delete at the end of columns
                if ($i == count($rowvalue) - 1) {
                    echo "<input  type='hidden' name='tablename' value='{$table}' />\n                           <input  type='hidden' name='mainid' value='{$rowvalue['0']}' />";
                    echo "<td><a onclick=\"window.open('authentication/ineredit.php?tablename={$table}&edit={$rowvalue['0']}','Update Recors','scrollbars=1,resizable=1,width=600,height=640')\" style=\"cursor: pointer;\">Edit</a></td><td><input  form='myform_{$counter}' type='submit' name='delete' value='Delete' class=\"btn btn-danger\"  style=\"cursor: pointer;\" /></td>";
                }
            }
        } else {
            for ($i = 0; $i < 8; $i++) {
                //get primry key for the fields less than 8
                $prima = mysql_get_foregin_key($table, $coulmtype['FieldsName'][$i]);
                if ($prima != '') {
                    //get FK tablename and primary key for the forgien key and the display name if exsist and its value
                    $FK = GetForeginKey_TableName($table, $prima);
                    $Tablename_FK = substr($FK[$prima], 0, strpos($FK[$prima], '.'));
                    // add the button to get all info for this primary key from the related table
                    @($fktables = GetForgienTablename_ForSpecific_Tablename($table));
                    @($fktablesname = substr($fktables[$limtbuttonrepeat], 0, strpos($fktables[$limtbuttonrepeat], '.')));
                    @($fkidname = end(explode(".", $fktables[$limtbuttonrepeat])));
                    if ($limtbuttonrepeat < count($fktables) && $fktablesname != '') {
                        echo "<a id='displayrelatedrecords' onclick=\"window.open('authentication/displayrelatedinfo.php?tablename={$table}&relatedinfo={$fktablesname}&fkfieldname={$fkidname}&relatedid={$rowvalue['0']}&true','Display Related Info','scrollbars=1,resizable=1,width=1200,height=640')\" style=\"cursor: pointer;margin-bottom:10px;margin-right:10px;display:none\" class='btn btn-info'>Display " . " " . ucfirst($fktablesname) . "</a> ";
                    }
                    $limtbuttonrepeat++;
                    $PK_Name_For_FK = end(explode(".", $FK[$prima]));
                    $FKNAME = $coulmtype['FieldsName'][$i];
                    $PK_Value_For_FK = $rowvalue[$i];
                    if (!empty($Forgien_Key_Display_Field)) {
                        if (array_key_exists($Tablename_FK, $Forgien_Key_Display_Field)) {
                            $FK_Field_Display = $Forgien_Key_Display_Field[$Tablename_FK];
                            @($FK_Query = QueryResult("SELECT * FROM {$Tablename_FK}  WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' "));
                            while (@($FKRow = mysql_fetch_array(@$FK_Query))) {
                                echo "<td>" . $FKRow[$FK_Field_Display] . "</td>";
                            }
                            echo "<input  type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" display_name=\"{$FK_Field_Display}\" value=\"{$Tablename_FK}\">";
                        } else {
                            @($FK_Query = QueryResult("SELECT * FROM {$Tablename_FK}  WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' "));
                            while (@($FKRow = mysql_fetch_array(@$FK_Query))) {
                                echo "<td>" . substr($FKRow[0], 0, 60) . "</td>";
                            }
                            echo "<input  type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\"  value=\"{$Tablename_FK}\">";
                        }
                        //end of array has no value for this tablename
                    } else {
                        $FK_Query = QueryResult("SELECT * FROM {$Tablename_FK}  WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' ");
                        while ($FKRow = mysql_fetch_array($FK_Query)) {
                            echo "<td>" . substr($FKRow[0], 0, 60) . "</td>";
                        }
                        echo "<input  type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\"  value=\"{$Tablename_FK}\">";
                    }
                } else {
                    //prepare the variables for youtube and viedo and images
                    if (count($confObj) > 0) {
                        if ($confObj['fieldname_image'] != '') {
                            $images = $confObj['fieldname_image'];
                        } else {
                            $images = 'Image';
                        }
                        if ($confObj['youtubefieldname'] != '') {
                            $youtube = $confObj['youtubefieldname'];
                        } else {
                            $youtube = 'YouTube';
                        }
                        if ($confObj['viedofieldname'] != '') {
                            $viedo = $confObj['viedofieldname'];
                        } else {
                            $viedo = 'Video';
                        }
                    } else {
                        $youtube = 'YouTube';
                        $viedo = 'Video';
                        $images = 'Image';
                    }
                    //check for youtube
                    if (preg_match('/' . $youtube . '/', $coulmtype['FieldsName'][$i])) {
                        if (@$rowvalue[$i] != '') {
                            echo "<td><iframe src='{$rowvalue[$i]}' width='130' height='100' frameborder='0' scrolling='no' allowfullscreen></iframe></td>";
                        } else {
                            echo "<td><img src='images/youtube.png' style='width:130px;height:80px;border-radius: 10px;'/></td>";
                        }
                    } else {
                        if (preg_match('/' . $viedo . '/', $coulmtype['FieldsName'][$i])) {
                            if (@$rowvalue[$i] != '') {
                                echo "<td><video width='320' height='240' controls><source src='{$rowvalue[$i]}' type='video/mp4'></video>  </td>";
                            } else {
                                echo "<td><img src='images/video.png' style='width:130px;height:80px;border-radius: 10px;'/></td>";
                            }
                        } else {
                            if (preg_match('/' . $images . '/', $coulmtype['FieldsName'][$i]) && $coulmtype['OrginalFieldType'][$i] != "blob" && $coulmtype['FieldType'][$i] != "text") {
                                //same code for the blob type but we check for the name incase the type is not blob
                                if ($rowvalue[$i] == '') {
                                    echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                } else {
                                    echo "<td><img src='authentication/uploads/{$rowvalue[$i]}' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                }
                            } else {
                                if ($coulmtype['OrginalFieldType'][$i] == "blob" && $coulmtype['FieldType'][$i] != "text") {
                                    if ($rowvalue[$i] == '') {
                                        echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                    } else {
                                        echo "<td><img src='data:image/jpeg;base64," . base64_encode($rowvalue[$i]) . "' style='width:80px;height:80px;border-radius: 10px;'/></td>";
                                    }
                                } else {
                                    echo "<td>" . substr($rowvalue[$i], 0, 40) . "</td>";
                                }
                            }
                        }
                    }
                }
                //end of primary key
                // add the edit and delete at the end of columns
                if ($i == 8 - 1) {
                    echo "<input  type='hidden' name='tablename' value='{$table}' />\n                           <input  type='hidden' name='mainid' value='{$rowvalue['0']}' />\n                           <td><a onclick=\"window.open('authentication/ineredit.php?tablename={$table}&edit={$rowvalue['0']}','Update Records','scrollbars=1,resizable=1,width=600,height=640')\" style=\"cursor: pointer;\">Edit</a></td><td><input  form='myform_{$counter}' type='submit' name='delete' value='Delete' class=\"btn btn-danger\"  style=\"cursor: pointer;\" /></td>";
                }
            }
        }
        //end of if number of col more less than 8
        echo "</tr></form>";
        $counter++;
    }
    //end of while loop
    // displaying paginaiton.
    echo pagination($statement, $per_page, $page, $url = '?', $table);
}
if (isset($_GET['tablename']) && isset($_GET['newrecord'])) {
    # code...
    $tablename = mysql_real_escape_string($_GET['tablename']);
    echo "<div id='table_title' >\n\t<h1 style='margin-left: 14px;color:#4E5E6A;'>" . strtoupper($tablename) . "</h1>\n\t</div><table>";
    //build the form
    $table_submit_info = GetCoulmsInfo($tablename);
    @($PrimryKey_DisplayName = $table_submit_info['FieldsName'][0]);
    @($colum_submit_name_no_replace = $table_submit_info['FieldsName']);
    @($colum_submit_name = str_replace('_', ' ', $table_submit_info['FieldsName']));
    @($colum_submit_type = $table_submit_info['FieldType']);
    @($colum_submit_orginaltype = $table_submit_info['OrginalFieldType']);
    @($colum_submit_number = $table_submit_info['columnnumber']);
    $fkfieldname = mysql_real_escape_string($_GET['fkfieldname']);
    $relatedid = mysql_real_escape_string($_GET['relatedid']);
    //get all config info if exsist
    @($confObj = CheckconfigInfo());
    //prepare the variables for youtube and viedo and images
    if (count($confObj) > 0) {
        if ($confObj['fieldname_image'] != '') {
            $images = str_replace('_', ' ', $confObj['fieldname_image']);
        } else {
            $images = 'Image';
        }
        if ($confObj['passwordfieldname'] != '') {
            $password = str_replace('_', '', $confObj['passwordfieldname']);
        } else {
            $password = '******';
        }
        if ($confObj['uploaddirectory'] != '') {
            $uploads = $confObj['uploaddirectory'];
        } else {