alexmahone Posted September 16, 2013 Share Posted September 16, 2013 Hi , I have "testdb.s3db" sqlite database in the project folder.. I have created few records in a table also, I'm stuck in retrieving the records in GridView .. I need your kind attention want a solution asap .. .. Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/ Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 Where exactly are you stuck? Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/#findComment-1449650 Share on other sites More sharing options...
Solution priyankagound Posted September 16, 2013 Solution Share Posted September 16, 2013 Hi, Below is the code which may help you to come out with the answer you looking for. <?php try { //open the database $db = new PDO('sqlite:/var/databases/307Code/python/readings.db'); //now output the data to a simple html table... print "<table border=1>"; print "<tr><td>Date & Time Recieved</td><td>Node</td><td>Temp</td><td>Hum</td><td>Light</td><td>Dew</td></tr>"; $result = $db->query('SELECT * FROM readingstable'); foreach($result as $row) { print "<tr><td>".$row['Recieved']."</td>"; print "<td>".$row['Node']."</td>"; print "<td>".$row['Temp']."</td>"; print "<td>".$row['Hum']."</td>"; print "<td>".$row['Light']."</td>"; print "<td>".$row['Dew']."</td></tr>"; } print "</table>"; // close the database connection $db = NULL; } Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/#findComment-1449662 Share on other sites More sharing options...
alexmahone Posted September 16, 2013 Author Share Posted September 16, 2013 im stuck in putting the records into grid view ... i'm looking for a code snippet.. thank u Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/#findComment-1449664 Share on other sites More sharing options...
Barand Posted September 16, 2013 Share Posted September 16, 2013 I haven't used sqlite but I think you need $result = $db->query('SELECT * FROM readingstable'); while($row = $result->fetch()) { Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/#findComment-1449679 Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 im stuck in putting the records into grid view ... i'm looking for a code snippet.. thank u We are not here to write code for people, the manual is full of examples. What have you tried? Be specific. Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/#findComment-1449680 Share on other sites More sharing options...
alexmahone Posted September 16, 2013 Author Share Posted September 16, 2013 Thank u priyankagound Quote Link to comment https://forums.phpfreaks.com/topic/282177-displaying-contents-of-sqlite-database-in-php/#findComment-1449685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.