Welcome Guest, Not a member yet? Register   Sign In
Display certain records only
#1

[eluser]shailendra[/eluser]
I have a projects and bid table. A user bids for a project which are open and haven't expired. A project expires if current date exceeds no. of days the project is to be displayed from the day the project is posted.
For example if a project is posted on 1st July and no. of days to display the project is 5 days then on 6 July the project expires and is not displayed to users for bidding.

I have a controller project.php
Code:
function days_left_for_expiry($proj_posted_date,$job_display_days)
    {
        $proj_posted_date=date('d-m-Y',strtotime($proj_posted_date));
        echo "projectposteddate ".$proj_posted_date;
        $no_of_days="+".$job_display_days." day";
        $expiry_date=strtotime($no_of_days,strtotime($proj_posted_date));
        echo "displayenddate ".date('d-m-Y',$expiry_date);
        $todays_date=date("d-m-Y");
        $difference=$expiry_date-strtotime($todays_date);
        $days_left=round($difference / 86400);
        return $days_left;
    }

    function my_projects()
    {
        $data=array();
        $projects=array();
        $userid=$this->session->userdata('userid');
        $status=$this->uri->segment(3);
        $data=$this->dashboard();
        //echo $status;
        /*Bidding-in-progress*/
        if($status=='open'){
            $this->load->model('project_model');
            $this->load->model('bid_model');
            $projects=$this->project_model->projects_by_user($userid,'open');
            foreach($projects as $project){
                $project->bid_count=$this->bid_model->no_of_bids($project->proj_id);
                $project->days_left=$this->days_left_for_expiry($project->date_time,$project->job_display_days);
                if($project->days_left>0)// This line of code doesn't work
                {
                    $data['projects']=$project;
                }
            }
            
            $this->load->view('myprojects_view',$data);
        }
        
    }

So in $data['projects'] I don't want to store projects which have expired. How do I do this???
#2

[eluser]shailendra[/eluser]
Please help on this.
#3

[eluser]Wondering Coder[/eluser]
you can just do this in a query. Read about scripting.
#4

[eluser]shailendra[/eluser]
Expiry date is not a field in projects table. Please help me to do in CI code?
#5

[eluser]shailendra[/eluser]
Isn't there any way to do this in CI php code?




Theme © iAndrew 2016 - Forum software by © MyBB