[SOLVED]logic help

if you check my code, it displays an "Edit" button that links to "Create" if the number of data is less than 3.

else it’ll link the “Edit” button to “Update” if the number of data is already 3.

now the problem is that, when the number of rows/item is equal to 3, only 1 edit button is being displayed

and only the first item in the list is linked to the edit button and I can’t update the rest. I want the “Edit”/update button to appear next to each of the item, or if the items is less than 3, I want the “Edit”/update button to appear beside each “But” there’s an "Edit/"create button at the bottom

how to solve this ? ???




                   $work = Wsrecruitworkhistory::model()->find(array(

                    'condition' => 'ResumeID=:id',

                    'params' => array(':id' => $model->ResumeID),));

                      if($this->findcv($model->ResumeID) && Yii::app()->request->getQuery('uid') == Yii::app()->user->id){

                            if(!is_null($work))

                            {

                                    $numwork = Wsrecruitworkhistory::model()->findAll(array(

                                    'condition' => 'ResumeID=:id',

                                    'params' => array(':id' => $model->ResumeID),

                                ));

                               if(count($numwork) == 3)

                               {

                                 echo  CHtml::link('Edit',array('wsrecruitworkhistory/update','id'=>$work->WorkHistoryID),array('class'=>'edit'));

                               }

                               elseif(count($numwork) < 3)

                               {

                                 echo  CHtml::link('Add',array('wsrecruitworkhistory/create','id'=>$model->ResumeID),array('class'=>'edit'));

                               }

                           }

                            if(is_null($work))

                            {

                               echo CHtml::link('Add',array('wsrecruitworkhistory/create','id'=>$model->ResumeID),array('class'=>'edit'));

                            }

                      }


                    ?>

                    </h2>

                    <p>

                       <?php

                            $work = Wsrecruitworkhistory::model()->findAll(array(

                                'condition' => 'ResumeID = :id',

                                'params' => array(':id'=>$model->ResumeID),

                            ));

                            if(!is_null($work))

                            {

                              foreach($work as $item => $val)

                               {

                                   

                                   echo "Date From = " .$val->DateFrom."<br />";

                                   echo "Date To = ". $val->DateTo. "<br />";

                                   echo "Title = " . $val->Title . "<br />";

                                   echo "Summary = ". $val->Summary ."<br />";

                                   echo "Place Organization = " . $val->PlaceOrganization . "<br />";

                                   echo "Work Responsibilities = " . $val->WorkResponsibilities . "<br />";

                                   echo "Work Details = " . $val->WorkDetails . "<br />";

                                   echo "Salary = " . $val->Salary . "<br />";

                                   echo "<br />";

                               }

                            }

                        ?>



nevermind…i’ve solved it in my own way lol