view:
<?phpforeach($row as $b):?> 

<?php echo $b->Product_Name ?></h3>
                      <?php echo $b->Price ?></p>



                     </div>
                     <?php if ($b->Option_name):?>
                            <?php echo form_label($b->Option_name, 'option_'.$b->Product_ID ); ?> 

                           <?php echo form_dropdown(
                           $b->Option_name,
                           $b->Option_value,
                           NULL,
                           'Product_ID= " option_' .$b->Product_ID. ' " '


                           );?>

                        <?php endif; ?>

controller:
public function product_detail($Product_ID){

            $this->load->model('model_products');

        $data['row']= $this->model_products->get_detail($Product_ID);



        $this->load->view('product_detail',$data);
}

model:
   function get_detail($Product_ID){
                       $this->db->from('products');
        $this->db->where('Product_ID',$Product_ID);
        $query= $this->db->get('');
       if  ($query->num_rows()==1) {
            foreach($query->result() as $row){
                $data[]=$row;
            }

       }
        return $data;
        }

codeignitor 
i m get warning : Invalid argument supplied for foreach()   I thing it is dropdown                  

can you do ?

print_r($data['row']);

ya output is Undefined variable: data
but when <?php print_r($row);?>
then out is :
Array ( [0] => stdClass Object ( [Product_ID] => 9 [cat_id] => 2 [s_cat_id] => 0 [Product_Name] => TShirt [Product_Description] => [Product_Detail] => Pure Cotton [Price] => 400.00 [Option_name] => Size [Option_value] => Small,Medium,Large [Image] => Tshirt.jpg [Units_in_stock] => 0 [Re-Order_level] => 0 [display] => 0 ) )

can you change and test your model with this code?

function get_detail($Product_ID)
{
    $this->db->from('products');
    $this->db->where('Product_ID',$Product_ID);
    $query= $this->db->get('');
    if ($query->num_rows() >0 ) {

    return $query->result();

    }

     /// return false;
}

this

return $query->result();

allows you to access the $row in view as object.,

while this one will allow you to index the array e.g. $row['column_name'].

    return $query->result_array();

by the way, you don't really need to do this

 $query= $this->db->get('');

this should be the proper way

 $query= $this->db->get();

the reason is that the database active record class method for get is declared like this

public function get($table = '', $limit = null, $offset = null)

What does the above method tells us is that the parameter table has been predefined as '' as empty, while the $limit and the $offset parameters are predefined as null.

I know this bring up many arguments about all the parameters are equally the same. In theory, they may appear to be equal but the null will return false if evaluated if it is set, while the '' or "" will definitely return true. However, the most revealing truth that these 3 parameters are not equally the same at any point is this. If '' or "" is evaluated as is_null() it is definitely false, but all will evaluate to true if evaluated as empty(). Whereas in the comparator operators, these three will also have a hair line difference. Null is true if compared as == and ===, while '' and "" will become false in === and true in ==.

That is pretty important stuffs in dealing things in Obejcts and methods. So, we don't really do this

if($query->num_rows()== 1)

the reason is that the numerical rows carries a default value of 0 ONLy in this regards, so if we do this

if($query->num_rows()> 0)

that should give us true or false response. I mean false conversion to true if the default is 0 at idle.

ok i did that but every thing still same

problably just a past error line 2:
<?phpforeach($row as $b):?>
must be
<?php foreach($row as $b):?>

but where is the endforeach;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.