Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * PHP Grid Component
- *
- * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
- * @version 1.4.8
- * @license: see license.txt included in package
- */
- // set up DB
- $conn = mysql_connect("localhost", "root", "");
- mysql_select_db("griddemo");
- mysql_query("SET NAMES 'utf8'");
- session_start();
- // preserve selection for ajax call
- if (!empty($_POST["tables"]))
- {
- $_SESSION["tab"] = $_POST["tables"];
- $tab = $_SESSION["tab"];
- }
- // update on ajax call
- if (!empty($_GET["grid_id"]))
- $tab = $_SESSION["tab"];
- if (!empty($tab))
- {
- // include and create object
- $base_path = "../../lib/";
- include($base_path."inc/jqgrid_dist.php");
- $g = new jqgrid();
- // set few params
- $grid["caption"] = "Grid for '$tab'";
- $grid["autowidth"] = true;
- $g->set_options($grid);
- // set database table for CRUD operations
- $g->table = $tab;
- // render grid
- $out = $g->render("list1");
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html>
- <head>
- <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
- <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
- <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
- <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
- <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
- <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
- </head>
- <body>
- <form method="post">
- <fieldset>
- <legend>Database Tables</legend>
- Select: <select name="tables">
- <?php
- $q = mysql_query('SHOW TABLES');
- while($rs = mysql_fetch_array($q))
- {
- $sel = (($rs[0] == $_POST["tables"])?"selected":"");
- ?>
- <option <?php echo $sel?>><?php echo $rs[0]?></option>
- <?php
- }
- ?>
- </select>
- <input type="submit" value="Load Table">
- </fieldset>
- </form>
- <br>
- <fieldset>
- <?php echo $out?>
- </fieldset>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement