MongoDB Part 3 : Simple Todo List with PHP and MongoDB

This tutorial help to understand mongodb connection functionality with php and will get the result set from mongodb database to display into html table grid.This is beginner tutorial for mongodb and PHP.Mongodb is very popular nosql database and php is a very famous open source web scripting language.I am creating simple example to read data from mongodb database and parse data into php server side.

We will follow following simple steps to connect php to mongodb database using Mongo php driver,Previously i have illustrated how to install mongodb and how to install mongodb driver in your xampp windows server.

listing-mongodb-with-php

You can also check other tutorial of MongoDB and PHP,

Simple Listing Example of Mongodb with PHP

Step 1: We will start mongodb server using 'mongod' command,you can type 'mondod' in window command line and press enter.If you haven’t install please refer previous tutorial.

Step 2: We will create a index.php file data will contain connection string for mongodb with php and table listing html code to display records.

Step 3: Creating connection with mongodb and php using below code,Please put below code into top of the index.php file.

Step 4: Iterating on mongodb result set using for-each loop using below code,Please put below code in body section of the index.php file.

Conclusion

This php mongodb tutorial help to display simple listing of all mongodb records into html table,You can add/edit record data using mongodb command line query.I left add,edit and delete functionality from UI side.You can do it yourself.