ram4nd Posted February 15, 2010 Share Posted February 15, 2010 Here is a problem, the value should appear where it's commented, but it doesn't. I can post my model as-well, but i think it's unnecessary. function _categories_for_tutorial_boxes($last_category_id) { static $return, $category, $categories; $category = $this->model->get_category($last_category_id); echo $category->parent_id; //Shows value here while($category->parent_id <= 0) { echo $category->parent_id; //Doesn't show any value here $categories['name'][] = $category->name; $categories['url_name'][] = $category->url_name; $category = $this->model->get_category($category->parent_id); } Link to comment https://forums.phpfreaks.com/topic/192109-problem-with-while-loop/ Share on other sites More sharing options...
Thierry Posted February 15, 2010 Share Posted February 15, 2010 Might have to do with it being an integer, printing them won't give a result. Try to adding "". before it and see if it works then. Link to comment https://forums.phpfreaks.com/topic/192109-problem-with-while-loop/#findComment-1012460 Share on other sites More sharing options...
khr2003 Posted February 15, 2010 Share Posted February 15, 2010 on this line: while($category->parent_id <= 0) { are you trying to compare values bigger than zero or less than zero. the statement shows that you want to loop all values less or equal to zero Link to comment https://forums.phpfreaks.com/topic/192109-problem-with-while-loop/#findComment-1012461 Share on other sites More sharing options...
ram4nd Posted February 15, 2010 Author Share Posted February 15, 2010 on this line: while($category->parent_id <= 0) { are you trying to compare values bigger than zero or less than zero. the statement shows that you want to loop all values less or equal to zero I need to rotate until it gets equal with zero Link to comment https://forums.phpfreaks.com/topic/192109-problem-with-while-loop/#findComment-1012549 Share on other sites More sharing options...
ram4nd Posted February 15, 2010 Author Share Posted February 15, 2010 problem solved with do while Link to comment https://forums.phpfreaks.com/topic/192109-problem-with-while-loop/#findComment-1012550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.