Fetching Data From Database,
There is mainly two function that can be used to fetch data in php
1. mysql_fetch_array() : Returns values as arrays.
2. mysql_fetch_object() : Return object
<?php
$select = "select * from <table_name>";
$result = mysql_query($select);
?>
1. mysql_fetch_array()
<?php
$data=mysql_fetch_array($result);
$optionField1 = $data['fieldname1'];
$optionField2 = $data['fieldname2'];
?>
2. mysql_fetch_object()
<?php
$data=mysql_fetch_object($result);
$optionField1 = $data->fieldname1;
$optionField2 = $data->fieldname2;
?>
Thank You!
There is mainly two function that can be used to fetch data in php
1. mysql_fetch_array() : Returns values as arrays.
2. mysql_fetch_object() : Return object
<?php
$select = "select * from <table_name>";
$result = mysql_query($select);
?>
1. mysql_fetch_array()
<?php
$data=mysql_fetch_array($result);
$optionField1 = $data['fieldname1'];
$optionField2 = $data['fieldname2'];
?>
2. mysql_fetch_object()
<?php
$data=mysql_fetch_object($result);
$optionField1 = $data->fieldname1;
$optionField2 = $data->fieldname2;
?>
Thank You!
No comments:
Post a Comment