Monday, October 31, 2016

Some important points about C++you might not know despite being a C++ Programmer!

However good programmer you might be, there are 90% chances that you don't know following things about C++
1. C++ follows Object oriented programming principles which can be explained by encapsulation, data hiding, polymorphism, abstraction and inheritance.

Wednesday, October 26, 2016

How to view all the values from a database in php and My Sql?

So you are having a Database and wants your users to view that data comfortably in a web browser.
In this post we will see how this is done along with an example.
Let us say that you have a database named "diwali" with a table which is also named "diwali" and you want to list all the fields in a suitable format in a web browser.


Let us say we have sno, name, email and phone no of a user stored in our database.
We can then use following code in our php to print the values of these fields :
<?php

// Connect to server and select database.
$host = "localhost";
$username = "root";
$password = "";
$db_name="diwali";

// Connect to server and select database.
$conn = new mysqli($host, $username, $password,$db_name);
$connectionHandle = mysqli_connect($host, $username, $password, $db_name);
$getQuery = "SELECT * FROM diwali ORDER BY sno ;";
$handle = mysqli_query($connectionHandle, $getQuery);
?>


<?php
while($row = mysqli_fetch_array($handle)){

echo '
<tr>
<td>'.$row['sno'].'</td>

                       <td>'.$row['name'].'</td>
<td>'.$row['email'].'</td>
<td>'.$row['phone'].'</td>
</tr>';
}
 ?>