Here is an example:
<PRE name = "code" class = "html"> <? PHP // $ text = "Hello the world"; // echo $ text; // connect // $ dburl = '2017. 29.34.183 '; // $ Port = '000000'; $ M = new Mongo ('2017. 29.34.183: 27017 '); // select a database $ db = $ M-> imagelist; // select a collection (analogous to a relational database's table) $ collection = $ db-> tags; // Add a record // $ OBJ = array ("title" => "Calvin and Hobbes ", "author" => "Bill Watterson"); // $ collection-> insert ($ OBJ); // Add anot Her record, with a different "shape" // $ OBJ = array ("title" => "XKCD", "online" => true ); // $ collection-> insert ($ OBJ); // find everything in the collection $ cursor = $ collection-> Find (); $ Facer = ''; $ imageurl = ''; $ imagetags =''; $ locationname = ''; $ locationtag =''; $ categary = ''; $ time = ''; $ COUNT = 0; foreach ($ cursor as $ post) {// $ Facer [$ count] = $ post ['faceresresult']; $ imageurl [$ count] = $ post ['url' ]; // $ HTTP = $ post ['url']; // print_r ($ post ['url']); $ imagetags [$ count] = $ post ['imagetags ']; $ locationname [$ count] = $ post ['locationname']; $ locationtag [$ count] = $ post ['locationtag']; $ categary [$ count] = $ post ['category']; $ time [$ count] = $ post ['time']; $ COUNT = $ count + 1;} // $ imageurl = explode ("", $ imageurl ); $ NO = 90; $ random = mt_rand (1, $ No); $ image = $ imageurl [$ random]; // $ face = $ Facer [$ random ]; $ Locname = $ locationname [$ random]; $ loctag = $ locationtag [$ random]; $ cat = $ categary [$ random]; $ imagetime = $ time [$ random]; $ imgtag = $ imagetags [$ random]; // output result echo '<center> </center> <br> <center> <div> location :'. $ locname. '</div> </center> <div> location tags :'. $ loctag. '</div> </center> <div> image time :'. $ imagetime. '</div> </center> <center> <Div> category :'. $ cat. '</div> </center> <div> image tags :'. $ imgtag. '</div> </center> <input type = "button" style = "width: 70" width = 70 value = "Next" onclick = "javascript: window. location. reload (); "/> <center> '; // iterate through the results // echo var_dump ($ cursor);?>