Dupecheck Function
[code]
        function dupeCheck()
        {

                $request = 
strtolower($this->input->get_post('bus_number',TRUE));

                $action = strtolower($this->input->get_post('action',TRUE));

                $results = $this->business->getBusinessbyNumber($request);

                $valid = 'false';

                if ($action == 'new')
                {
                        if (!$results)
                        {
                                $valid = 'true';
                        }
                }
                elseif ($action == 'edit')
                {
                        $bus_id = $this->input->get_post('bus_id',TRUE);

                        $id_search = $this->business->getBusinessbyId($bus_id);

                        foreach ($id_search as $row)
                        {
                                $returned_number = 
strtolower($row['bus_number']);
                        }
                        if ($returned_number == $request)
                        {
                                // Comparison made by bus_id to ensure the 
bus_number has not
changed.
                                // Editing a business but not changing the 
bus_number.
                                $valid = 'true';
                        }
                        else
                        {
                                if (!$results)
                                {
                                        $valid = 'true';
                                }
                        }
                }

                echo $valid;
        }
[/code]


Reply via email to