Object Oriented Programming, or OPP refers to the method of programming that invokes the use of classes to organize the data and structure of an application. object function code easy to fetch in database most of the programmer using oops principals. why because oops method easy to handle the coding very simple functions.
Fetch Array function
This coding fetch the database value using array function create and insert any sample values in database after using this coding.
<select name="main_menu" id="main_menu" >
<option value="">--select menu--</option>
<?php
$select=mysql_query("select * from menu1_tbl");
while($menu1=mysql_fetch_array($select))
{
?>
<option value="<?php echo $menu1['id'];?>"> <?php echo $menu1['menu_name'];?></option>
<?php
}
?></select>
Fetch Object function
This coding fetch database value in object method using oops concept function.
just value fetch the object function <?php $menu1->menu_name;?>
<select name="main_menu" id="main_menu" > <option value="">--select menu--</option> <?php $select=mysql_query("select * from menu1_tbl"); while($menu1=mysql_fetch_object($select)) { ?> <option value="<?php $menu1->id;?>"> <?php $menu1->menu_name;?></option> <?php } ?> </select>
Dear brother using mysqli or PDO ..
ReplyDeleteHi, Nice description about Array using fetch query in php oops concept.Thanks, its really helped me......
ReplyDelete-Aparna
Theosoft