How to retrieve the value from the database example?
Retrieve the value from the DataBase
To retrieve the value from the data base we have to create a connection with the database with the help of php code and html to show the value and database to store the value.
Now the first step is to create a connection between the database and php code: –
$con=mysqli_connect(“localhost”,”root”,””,”job_portal”);
It create a connection with the database :-
Now the second step is to create query about what we want to fetch the data from the database
$query=mysqli_query($con,”select * from jobs”);
Here we select the whole value from the database table name jobs
Now the next step is to fetch the data from the query
while($row=mysqli_fetch_array($query))
{
It will fetch the data from the database
Next step is how to show the data
Echo $row[‘column_name’];
Eg.
while($row=mysqli_fetch_array($a))
{?>
” height=”50px” width=”50px”/>
<span><img src=”webpic/cmpny.jpg” width=”10px” height=”10px”><?php echo $row[‘title’];?></span>
<span><img src=”webpic/lo.png” width=”10px” height=”10px”><?php echo $row[‘location’];?></span>
<span><img src=”webpic/lo.png” width=”10px” height=”10px”><?php echo $row[‘city’];?></span>
</div>
</div>
<?php echo $row[‘require’];?>
<?php echo $row[‘experience’];?>
<?php echo $row[‘studies’];?>
<?php echo $row[‘position_type’];?>
<?php echo $row[‘contact’];?>
<?php echo $row[‘shift’];?>
<?php echo $row[‘salary’];?>
</div>
<?php }
Now the last step is close the connection which we create to fetch the data
mysqli_close($con);
?>
With that easy method we can easily fetch the data from the database.we can also set the limit with the help of limit into the query like Select * from table_name limit 5.
For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666
Email:info@technocampus.co.in
**************************************************************************************************************