Welcome Guest, Not a member yet? Register   Sign In
If file has been quoted "noob stuck"
#1

[eluser]FireMe[/eluser]
Hi all,

This is probably a noob question but the easy things always seem to stump me, I am working on a personal practice project because I am trying to get into php and mysql, codeigniter seems to be one of the best open source frameworks I believe, well I have not done so bad for my ability I have a login and register system with capatcha set up, I have a user upload page, a quote page.

on the upload page I have a foreach statement for the files that the logged in user has uploaded, and there is a link/button for delete and get quote for each, what I want to do is not show the delete and quote buttons if a quote has been inserted into that database for that file_id. and that it really how would I do this my code below. also if there is a better way to do anything in my code i would appreciate any suggestions.


controller function for upload page.
Code:
function upload() {
  $data['menu_top'] = $this->CI_menu->menu_top();
  $data['user_uploads'] = $this->CI_auth->get_all_files($this->CI_auth->logged_id());
  
  if($this->CI_auth->check_logged()===FALSE)
            redirect(base_url().'index.php/login/');
        else
  {
   $this->load->view('_upload_html', $data);
  }

}


controller function for quotes page
Code:
function quotes() {
  $data['menu_top'] = $this->CI_menu->menu_top();
  $data['user_quotes'] = $this->CI_auth->get_all_quotes($this->CI_auth->logged_id());
  
  if($this->CI_auth->check_logged()===FALSE)
            redirect(base_url().'index.php/login/');
        else
  {
   $this->load->view('_quotes_html', $data);
  }
}

and the models

Code:
function get_all_files($user_id){
$query = $this->db->query("SELECT * FROM file WHERE user_id = $user_id");
if($query->num_rows() > 0){
  foreach($query->result() as $row){
   $data[]=$row;
  }
  return $data;
}
else {
}
return false;
    }

function get_all_quotes($user_id){
$query = $this->db->query("SELECT * FROM quotes WHERE user_id = $user_id");
if($query->num_rows() > 0){
  foreach($query->result() as $row){
   $data[]=$row;
  }
  return $data;
}
else {
}
return false;
    }

Thanks,

And I will look forward from hearing from you

FireMe
#2

[eluser]FireMe[/eluser]
85 views no replies, did I not post enough of my code for a reply? thanks in advance, FireMe
#3

[eluser]quasiperfect[/eluser]
not sure about the whole system your building but i can give you a suggestion

if the user doesn't change the files to often and has a lot of files instead of requesting every time from db request once cache the result and recache on delete and upload





Theme © iAndrew 2016 - Forum software by © MyBB