{"id":14760,"date":"2016-09-27T16:15:50","date_gmt":"2016-09-27T13:15:50","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=14760"},"modified":"2018-01-09T10:27:15","modified_gmt":"2018-01-09T08:27:15","slug":"php-gridview-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/","title":{"rendered":"PHP GridView Example"},"content":{"rendered":"<p>In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML.<br \/>\nFor this example we will use:<\/p>\n<ol>\n<li>A computer with PHP&gt;= 5.5 installed<\/li>\n<li>notepad++<\/li>\n<li>Mysql Database<\/li>\n<\/ol>\n<p>A grid view or a data grid is a graphical control element that displays data in a tabular view. Gridview in PHP is especially used to display data pulled from a database.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<\/p>\n<h2>1. Getting Started<\/h2>\n<p>There are some commercial gridview software&#8217;s built to work with PHP but in this example we will build ours. We will create a simple web app that pulls data from a database and displays it in a gridview.<\/p>\n<p>If you are developing on your local machine, you can download and install wamp. Wamp installs both php, phpmyadmin and mysql on your local machine. Furthermore, wamp doesn\u2019t require any specific prior knowledge to get it working.<\/p>\n<h3>1.1 Initializing the database<\/h3>\n<p>This tutorial assumes you have php and mysql running. You should also create a database named authentication.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>db.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[6]\">&lt;?php\r\n$dsn = \"mysql:dbname=authentication\"; \r\n$username = \"root\"; \r\n$password = \"\"; \r\ntry{\r\n$conn = new PDO( $dsn, $username, $password );  \r\n$conn-&lt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);\r\n}\r\ncatch(PDOException $pd){\r\necho $pd-&lt;getMessage();\r\n}\r\n?&gt;\r\n<\/pre>\n<p>This script creates a connection to the database. We are using PDO (Php data objects) to access our database. The connection is stored in the $conn object and it is made available to manipulate the database.<br \/>\nWe create a new PDO object in line 6 and surround it with a try\/catch statement, so as to catch any error that might occur while trying to connect to the database.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>init.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[2,5]\">&lt;?php\r\nrequire_once(\"db.php\");\r\ntry{\r\n$sql=\"create Table record(id smallint  unsigned not null AUTO_INCREMENT PRIMARY KEY, name VARCHAR(265) NOT NULL,email VARCHAR(265) NOT NULL,department VARCHAR(265) NOT NULL,position varchar(255) NOT NULL)\";\r\n$conn-&gt;exec($sql);\r\necho \"TABLE CREATED\";\r\n}\r\ncatch(PDOException $pd){\r\necho \"Error Creating Table: \" . $pd-&gt;getMessage();\r\n}\r\n$conn=null;\/\/close the database connection\r\n?&gt;\r\n<\/pre>\n<p>Before we start loading data into our gridview, you should load this script(init.php) into your browser (just once). The script creates a table that is called \u201crecord\u201d in the database, this table will contain all the data that will be loaded into our gridview.<br \/>\nIn line two we include the \u201cdb.php\u201d script to login to the database. In line 5 we create a table in our database by calling the $conn-&gt;exec($sql) method, which takes a string as a parameter (the string holds the sql query).<\/p>\n<h3>1.2 Inserting Data into the database<\/h3>\n<p>Let&#8217;s populate our database. There are two ways we can populate our database. One way to do it, is to load &#8220;insertdata.php&#8221; in our browser. It would populate our record table.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>insertdata.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[2,5]\">&lt;?php\r\nrequire_once(\"db.php\");\r\ntry{\r\n\/\/begin the transaction\r\n$conn-&gt;beginTransaction();\r\n\/\/our sql statements\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('John Jack','e@example.com','accounting','accountant')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Mary Daniel','e@example.com','accounting','accountant')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Peace Daniel','e@example.com','accounting','accountant')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Sean Micheal','e@example.com','accounting','accountant')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Olive Sarah','e@example.com','accounting','accountant')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Micheal pater','e@example.com','I.T','Web Developer')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Ayo Brooks','e@example.com','I.T','Senior Web And Mobile Developer')\");\r\n$conn-&gt;exec(\"INSERT INTO record(name,email,department,position)VALUES('Bran Judge','e@example.com','I.T','Senior Web And Mobile Developer')\");\r\n\/\/we commit the transaction\r\n$conn-&gt;commit();\r\necho \"New Record created successfully\";\r\n}\r\ncatch(PDOException $e){\r\n\/\/roll back the transaction\r\n$conn-&gt;rollback();\r\necho \"An error occured:\".$e-&gt;getMessage();\r\n}\r\n$conn=null;\/\/close the database connection\r\n\r\n\r\n?&gt;\r\n<\/pre>\n<p>The above script shows us that we can insert mutiple records into a database with PHP, using PDO(PHP DATA OBJECTS).<br \/>\nThe second way to populate our table is by\u00a0using HTML forms (doing it manually).<\/p>\n<p><span style=\"text-decoration: underline;\"><em>insertdata1.php<\/em><\/span><\/p>\n<pre class=\"brush:php; wrap-lines:false\">&lt;?php\r\nrequire_once(\"db.php\");\r\n?&gt;\r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\", \"verdana\", \"calibri\", \"san serif\";\r\n\toverflow: hidden;\r\n\tpadding: 0%;\r\n\tborder: 0%;\r\n\t}\r\n\t#hold{\r\n\t\tpadding: 20px;\r\n\t}\r\n\tinput[type= text]{\r\n\t\twidth: 20%;\r\n\t\theight: 30px;\r\n\t}\r\n\tinput[type= email]{\r\n\t\twidth: 20%;\r\n\t\theight: 30px;\r\n\t}\r\n\t\r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;Populate Database&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\t&lt;?php\r\n\tif(isset($_POST['submit'])){\r\n\t\t$name=$_POST['firstName'];\r\n\t\t$email=$_POST['lastName'];\r\n\t\t$department=$_POST['dept'];\r\n\t\t$position=$_POST['pos'];\r\n\tif(empty(trim($name))||empty(trim($email))||empty(trim($department))||empty(trim($position))){\r\n\t\techo \"Data Not Saved: No field should be empty &lt;br&gt;\";\r\n\t\techo \"&lt;a href=insertdata1.php&gt;Insert Another Data&lt;\/a&gt;\";\r\n\t\t\r\n\t}\r\n\telse{\r\n\t\t$sql=\"INSERT INTO record(name, email, department, position)VALUES(:name, :email, :department, :position)\";\r\n\t\t$st=$conn-&gt;prepare($sql);\r\n\t\t$st-&gt;bindValue(\":name\", $name);\r\n\t\t$st-&gt;bindValue(\":email\", $email);\r\n\t\t$st-&gt;bindValue(\":department\", $department);\r\n\t\t$st-&gt;bindValue(\":position\", $position);\r\n\t\t$st-&gt;execute();\r\n\t\t$st=null;\r\n\t\techo \"Data Saved &lt;br&gt;\";\r\n\t\techo \"&lt;a href=insertdata1.php&gt; Insert Another Data &lt;\/a&gt;\";\r\n\t}\r\n\t}\r\n\telse{\r\n\t?&gt;\r\n\t&lt;div id= hold&gt;\r\n\t&lt;form action=insertdata1.php method=post&gt; \r\n &lt;label for = firstName&gt; Name &lt;\/label&gt; &lt;br&gt;          &lt;input type=text name=firstName id=firstName required \/&gt; &lt;br&gt; &lt;br&gt;\r\n &lt;label for = lastName&gt; Email &lt;\/label&gt; &lt;br&gt;          &lt;input type=email name=lastName id=lastName  required\/&gt; &lt;br&gt; &lt;br&gt;\r\n &lt;label for = department&gt; department &lt;\/label&gt; &lt;br&gt;   &lt;input type=text name=dept id=dept required \/&gt; &lt;br&gt;  &lt;br&gt; \r\n&lt;label for = position&gt; position &lt;\/label&gt; &lt;br&gt;        &lt;input type= text name=pos id=pos required \/&gt; &lt;br&gt;  &lt;br&gt; \r\n&lt;input type=submit value= submit name= submit&gt;\r\n&lt;\/form&gt;\r\n&lt;\/div&gt;\r\n&lt;?php\r\n\t}\r\n?&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<h3>1.3 Display Data<\/h3>\n<p>Now lets display the data stored in our database.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>display.php<\/em><\/span><\/p>\n<pre class=\"brush:php;\">&lt;?php\r\n\/\/this connects to the database\r\nrequire_once(\"db.php\");\r\n?&gt;\r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\", \"verdana\", \"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\ttable{\r\n\t\tborder:2px solid black;\r\n\t\twidth:100%;\r\n\t}\r\n\tth,td{\r\n\t\twidth:20%;\r\n\ttext-align:center;\r\n    border:2px solid black;\t\r\n\t}\r\n\t\r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt; Display Saved Data In GridView &lt;\/title&gt;\r\n\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\t&lt;?php\r\n\t\/\/we create a table\r\n\techo \"&lt;table&gt;\";\r\n\t\/\/ create table th \r\n\techo \"&lt;tr &gt; &lt;th&gt; ID &lt;\/th&gt; &lt;th&gt; Name &lt;\/th&gt; &lt;th&gt; Departmant &lt;\/th&gt; &lt;th&gt; Position &lt;\/th&gt; &lt;th&gt; Email &lt;\/th&gt; &lt;\/tr&gt;\";\r\n\t$sql=\" select * from record \";\r\n\t$st=$conn-&gt;prepare($sql);\r\n\t$st-&gt;execute();\r\n\t$total=$st-&gt;rowCount();\/\/get the number of rows returned\r\n\tif($total &lt; 1 ){\/\/if no row was returned\r\n\t\techo \"&lt;tr&gt; &lt;td style&gt; No Data: DataBase Empty &lt;\/td&gt; \";\/\/print out error message\r\n\t\techo \"&lt;td&gt; No Data: DataBase Empty &lt;\/td&gt; \";\/\/print out error message\r\n\t\techo \" &lt;td&gt; No Data: DataBase Empty &lt;\/td&gt;\";\/\/print out error message\r\n\t\techo \" &lt;td&gt; No Data: DataBase Empty &lt;\/td&gt;\";\/\/print out error message\r\n\t    echo \"&lt;td&gt; No Data: DataBase Empty  &lt;\/td&gt;\";\/\/print out error message\r\n\t\t\r\n\t}\r\n\t\telse{\r\n\twhile($res = $st-&gt;fetchObject()){\/\/loop through the returned rows\r\n\t\techo \"&lt;tr&gt;\";\r\n\t\techo \"&lt;td&gt; $res-&gt;id &lt;\/td&gt; &lt;td&gt; $res-&gt;name &lt;\/td&gt; &lt;td&gt; $res-&gt;department &lt;\/td&gt; &lt;td&gt; $res-&gt;position &lt;\/td&gt; &lt;td&gt; $res-&gt;email &lt;\/td&gt;\";\r\n\t\techo\"&lt;\/tr&gt;\";\r\n\t}\r\n\t}\r\n\t?&gt;\r\n\t&lt;\/table&gt;\r\n\t&lt;p&gt;\r\n\t&lt;a href=insertdata1.php&gt; Insert Another Data &lt;\/a&gt;\r\n\t&lt;\/p&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p>We used HTML table to display our data in a gridview. Lets add a delete functionality to our app.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>display1.php<\/em><\/span><\/p>\n<pre class=\"brush:php;\">&lt;?php\r\n\/\/this connects to the database\r\nrequire_once(\"db.php\");\r\n?&gt;\r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\", \"verdana\", \"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\ttable{\r\n\t\tborder:2px solid black;\r\n\t\twidth:100%;\r\n\t}\r\n\tth,td{\r\n\t\twidth:15%;\r\n\ttext-align:center;\r\n    border:2px solid black;\t\r\n\t}\r\n\t\r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt; Display Saved Data In GridView &lt;\/title&gt;\r\n\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\t&lt;script&gt;\r\n\tfunction removes(id){\r\n\t\t\r\n\tvar ans = confirm(\"Are You Sure You Want To Delete This Row\");\r\n\tif(ans){\/\/if true delete row\r\n\t\twindow.location.assign(\"delete.php?id=\"+id);\r\n\t}\r\n\telse{\/\/if false \r\n\t\t\/\/ do nothing\r\n\t}\r\n\t}\r\n\t\r\n\t\r\n\t&lt;\/script&gt;\r\n\t&lt;?php\r\n\t\/\/we create a table\r\n\techo \"&lt;table&gt;\";\r\n\t\/\/ create table th \r\n\techo \"&lt;tr &gt; &lt;th&gt; ID &lt;\/th&gt; &lt;th&gt; Name &lt;\/th&gt; &lt;th&gt; Departmant &lt;\/th&gt; &lt;th&gt; Position &lt;\/th&gt; &lt;th&gt; Email &lt;\/th&gt; &lt;th&gt;   &lt;\/th&gt; &lt;\/tr&gt;\";\r\n\t$sql=\" select * from record \";\r\n\t$st=$conn-&gt;prepare($sql);\r\n\t$st-&gt;execute();\r\n\t$total=$st-&gt;rowCount();\/\/get the number of rows returned\r\n\tif($total &lt; 1 ){\/\/if no row was returned\r\n\t\techo \"&lt;tr&gt; &lt;td style&gt; No Data: DataBase Empty &lt;\/td&gt; \";\/\/print out error message\r\n\t\techo \"&lt;td&gt; No Data: DataBase Empty &lt;\/td&gt; \";\/\/print out error message\r\n\t\techo \" &lt;td&gt; No Data: DataBase Empty &lt;\/td&gt;\";\/\/print out error message\r\n\t\techo \" &lt;td&gt; No Data: DataBase Empty &lt;\/td&gt;\";\/\/print out error message\r\n\t    echo \"&lt;td&gt; No Data: DataBase Empty  &lt;\/td&gt;\";\/\/print out error message\r\n\t\t\r\n\t}\r\n\t\telse{\r\n\twhile($res = $st-&gt;fetchObject()){\/\/loop through the returned rows\r\n\t\techo \"&lt;tr&gt;\";\r\n\t\techo \"&lt;td&gt; $res-&gt;id &lt;\/td&gt; &lt;td&gt; $res-&gt;name &lt;\/td&gt; &lt;td&gt; $res-&gt;department &lt;\/td&gt; &lt;td&gt; $res-&gt;position &lt;\/td&gt; &lt;td&gt; $res-&gt;email &lt;\/td&gt; &lt;td&gt; &lt;a href=# onclick=removes($res-&gt;id)&gt; Delete &lt;\/a&gt; &lt;\/td&gt;\";\r\n\t\techo\"&lt;\/tr&gt;\";\r\n\t}\r\n\t}\r\n\t?&gt;\r\n\t&lt;\/table&gt;\r\n\t&lt;p&gt;\r\n\t&lt;a href=insertdata1.php&gt; Insert Another Data &lt;\/a&gt;\r\n\t&lt;\/p&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p>We updated our code to include the ability to delete any row, by simply clicking on the delete link at the end of each row.<br \/>\nAny click on delete, will call our function <code>remove()<\/code>, Which takes the id of the row to delete as a parameter. The <code>remove()<\/code> function loads the script &#8220;delete.php&#8221; Which does the actual deletion.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>delete.php<\/em><\/span><\/p>\n<pre class=\"brush:php;\">&lt;?php\r\nrequire_once(\"db.php\");\r\nif(isset($_GET['id'])){\r\n$id=$_GET['id'];\t\r\n$sql=\"DELETE FROM record where id= :id\";\t\r\ntry{\r\n$st=$conn-&gt;prepare($sql);\r\n$st-&gt;bindValue(\":id\", $id);\r\n$st-&gt;execute();\r\nheader(\"Location:display.php\");\r\n}\r\ncatch(PDOException $e){\r\n\techo \"An Error Occured: \". $e-&gt;getMessage();\r\n}\r\n}\r\nelse{\r\n\techo \"&lt;h1&gt;Wrong Request&lt;\/h1&gt;\";\r\n}\r\n\r\n$conn=null;\r\n?&gt;\r\n<\/pre>\n<p>This script does the actual deletion and redirects the browser (A preffered way to call the &#8220;delete.php&#8221; is AJAX).<\/p>\n<h2>2. Summary<\/h2>\n<p>In this example we learnt about gridviews, what are they and how to create them in PHP with HTML tables. We also added delete function to our gridview.<\/p>\n<h2>3. Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/09\/phpgridviewexample.zip\">phpgridviewexample<\/a><br \/>\n<\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we will use: A computer with PHP&gt;= 5.5 installed notepad++ Mysql Database A grid view or a data grid is a graphical control element that displays data &hellip;<\/p>\n","protected":false},"author":164,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-14760","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP GridView Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP GridView Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-27T13:15:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:27:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"PHP GridView Example\",\"datePublished\":\"2016-09-27T13:15:50+00:00\",\"dateModified\":\"2018-01-09T08:27:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\"},\"wordCount\":582,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\",\"name\":\"PHP GridView Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-09-27T13:15:50+00:00\",\"dateModified\":\"2018-01-09T08:27:15+00:00\",\"description\":\"In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/php\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP GridView Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP GridView Example - Web Code Geeks - 2026","description":"In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP GridView Example - Web Code Geeks - 2026","og_description":"In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-09-27T13:15:50+00:00","article_modified_time":"2018-01-09T08:27:15+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"PHP GridView Example","datePublished":"2016-09-27T13:15:50+00:00","dateModified":"2018-01-09T08:27:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/"},"wordCount":582,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/","name":"PHP GridView Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-09-27T13:15:50+00:00","dateModified":"2018-01-09T08:27:15+00:00","description":"In this example we will introduce the concept of gridviews. We will also learn how to display data in a gridview with PHP and HTML. For this example we","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/php\/php-gridview-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.webcodegeeks.com\/category\/php\/"},{"@type":"ListItem","position":3,"name":"PHP GridView Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=14760"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14760\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=14760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=14760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=14760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}