Welcome Guest, Not a member yet? Register   Sign In
db values
#1

[eluser]anpmtp[/eluser]
how to pic database row values without for each

i want data base values in for loop

function parent_categery($Id,$selId = 0, $sym='')
{
if($Id==0)
$gr='';
else
$gr=$sym.'>';
$this->load->database();
$this->db->select('*');
$this->db->from('categories');
$this->db->join('categories_description', 'categories_description.categories_id = categories.categories_id');
$this->db->where('parent_id',$Id);
$query=$this->db->get();
$data['Select']='Select';
$row=$query->result_array();
for($i=0; $i < $query->num_rows(); $i++)
{

$Id=$row['categories_id'];
$data[$row['categories_id']]=$gr.$row['categories_name'];
$this->parent_categery($Id,$selId, $gr);
}
if ($query->num_rows() > 0)
{
foreach($query->result_array() as $row)
{
$Id=$row['categories_id'];
$data[$row['categories_id']]=$gr.$row['categories_name'];
$this->parent_categery($Id,$selId, $gr);
}
}
return $data;


i want to use fore loop instead of foreach

plz help
#2

[eluser]danmontgomery[/eluser]
[quote author="anpmtp" date="1281352558"]i want to use fore loop instead of foreach[/quote]

Why?




Theme © iAndrew 2016 - Forum software by © MyBB