Database data foreach

Topics: Developer Forum, Project Management Forum, User Forum
May 20, 2010 at 5:42 PM

Hello and sorry for my English but I am Italian.
Collection of data from the database and put them in an array with a foreach loop fetch the values that interest me, but a video I print only the last value, how to resolve?

 

//contenuti cella
$co = mysql_query("SELECT * FROM categories_description WHERE language_id = 2");
while($ro = mysql_fetch_array($co)){
$cat_id[] = $ro[categories_id];
}

foreach($cat_id as $c_id){
    $query = mysql_query("SELECT p.products_model, c.categories_name FROM products as p, categories_description as c WHERE p.master_categories_id = $c_id AND c.categories_id = $c_id AND c.language_id = 2");
while($row = mysql_fetch_array($query)){

     $objPHPExcel->getActiveSheet()->setCellValue('A1', "$row[categories_name]");

     $objPHPExcel->getActiveSheet()->setCellValue('A2', "$row[products_model]");

}
}

 

 

But this way I print only the last value, both the model and the category name.

How can I fix it?

I hope I have been clear.


Thanks

May 20, 2010 at 9:53 PM
Sorry I forgot what I want, I want a page structured like this: Categories1 P.model1 P.model2 P.model3 P.model4 Categories2 P.model1 P.model2 P.model3 P.model4 and so on... Thanks