• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved]Strange problem with my retrieval record function:

#1
[eluser]brucebat[/eluser]
WAS CAUSED BY CORRUPTED DATABASE


Hi all,

I am experiencing a strange problem with my view record function.

Screenshot:

http://i.imgur.com/tyGvE.jpg

When I click the view button , it is saying no record returned however there is a record there otherwise my view would not generate that button.

The only time it works is on record #3. Why work on no.3

Here is just a screenshot to prove there is data
http://i.imgur.com/pBzVs.jpg

I have checked the view code and it is fine, I have a feeling it is the database or my query functions:

Here is the controller:

Code:
public function view_record()
        {
            $record_id = $this->input->post('procedure_id');
            
            $returned_record = $this->control_panel_model->view_record($record_id);
            

                         if ($returend_record->num_rows() > 0)
{
            foreach ($returned_record->result() as $row)
            {
                echo $row->name_id; //to test this works
                echo "hello";
            }
    }
                      else
                     {
                          echo "No records";
                     }
            return;
        }

Model function:

Code:
public function view_record($record_id)
        {
            $criteria = array
            (
                'procedure_id' => $record_id
            );
            
            $this->db->select('procedure.procedure_id, procedure.patient_id, procedure.department_id, procedure.name_id , procedure.dosage_id');
            $this->db->from ('procedure');
            
            $this->db->join('patient', 'patient.patient_id = procedure.patient_id', 'inner');
            $this->db->join('department', 'department.department_id = procedure.department_id', 'inner');
            $this->db->join('procedure_name', 'procedure_name.procedure_name_id = procedure.name_id', 'inner');
            $this->db->join('dosage', 'dosage.dosage_id = procedure.dosage_id', 'inner');
            
            $this->db->where('procedure_id', $record_id);
            $result = $this->db->get();
            
        
            return $result;


        }

So what do you think is wrong?

Thanks

#2
[eluser]byde[/eluser]
Can you post the view??

#3
[eluser]brucebat[/eluser]
Thankyou for your time!

Ok heres the view but I have a feeling it is not that because why would the 3rd record displayed on the view work and the rest don't?


Code:
<?php
                            //if there are nor records associated with that user then inform user
                            if ($user_records == 0)
                            {
                                echo '<tr>';
                                echo '<th>','No Records','</th>';
                                echo '</tr>';
                            
                            }
                            else
                            {
                                foreach ($user_records as $row)
                                {
                                    //create a table row
                                    echo '<tr>';
                                        //procedure id
                                        echo '<td>';
                                            echo $row->procedure_id;
                                        echo '</td>';
                                        
                                        //file link
                                        //if no file
                                        if ($row->edocument == NULL)
                                        {
                                            echo '<td>';
                                                echo "No file";
                                            echo '</td>';
                                            
                                            
                                        }
                                        //print link for file
                                        else
                                        {
                                            echo '<td>';
                                                echo '<b>',anchor('../records/'.$row->edocument, 'View File'), '</b>';
                                            echo '</td>';
                                        }
                                            
                                        //view record
                                        echo '<td>';
                                            echo form_open ('control_panel/view_record');
                                            echo '&lt;input name="procedure_id" type="hidden" value="', $row-&gt;procedure_id,'">';
                                            echo form_submit('view','View');
                                            echo form_close();
                                        echo '</td>';
                                        
                                        //update record
                                        echo '<td>';
                                            echo form_open ('control_panel/update_record');
                                            echo '&lt;input name="procedure_id" type="hidden" value="', $row-&gt;procedure_id,'">';
                                            echo form_submit('update','Update');
                                            echo form_close();
                                        echo '</td>';
                                        
                                        //standard users cannot delete only admins!
                                        
                                    echo '</tr>';
                                
                                }
                                
                            }
                            
                            ?&gt;

#4
[eluser]byde[/eluser]
would you mind to post what does var($user_records); print? just paste it at the end of your controller and post the result, this will tell us whats in your result set

#5
[eluser]brucebat[/eluser]
Thanks it is printing all the rows in my table associated with user_id = 2. All the columns are printed too as shown below.

76 times as there are 76 records associated with that user.

e.g.
Quote:procedure_id => 1
user_id => 2,
edocument => bob1.jpg,
.....etc.

#6
[eluser]byde[/eluser]
srry for asking a lot but it is difficult when not seen all the code

can you post var($returend_record); form the controler view_record() and your database query

#7
[eluser]brucebat[/eluser]
Thanks for your help byde,

I decided to wipe my database clean and reload it from backup.

I think the table was corrupted or something like that but now it works as intended.

Once again thanks for sticking with me, I guess you kinda inspired me to go wipe the database clean and thus solve the problem Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.