Tags » PHP 2

get recurring dates between two dates and periods php codeigniter

	public function getRecurringDates($start_date,$period,$weekdayNumbers = [])
	{
		$end_date = date("Y-m-d", strtotime("+$period days", strtotime($start_date)) );

	    $dateArr = array();

	    foreach ($weekdayNumbers as $key => $weekdayNumber) {


			$startDate = strtotime($start_date);
		    $endDate = strtotime($end_date);

	    	do
		    {
		        if(date("w", $startDate) != $weekdayNumber)
		        {
		            $startDate += (24 * 3600); // add 1 day
		        }
		    } while(date("w", $startDate) != $weekdayNumber);


		    while($startDate <= $endDate)
		    {
		        $dateArr[] = date('Y-m-d', $startDate);
		        $startDate += (7 * 24 * 3600); // add 7 days
		    }

	    }
		    
	    return($dateArr);
	}

        // die('lol');
	$event_id = (isset($_POST['event_id']))? 49 more words
Programming

getting lattitude and longitude by address


	public function getlatlang($address){

		

		$this->curl->create('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false');

		//  Rest Of The Code As In controller_curl.php

		$this->curl->option('connecttimeout', 600);

		// For SSL Sites. Check whether the Host Name you are connecting to is valid

		$this->curl->option('SSL_VERIFYPEER', false);



		//  Ensure that the server is the server you mean to be talking to

		$this->curl->option('SSL_VERIFYHOST', false);



		// Defines the SSL Version to be Used

		$this->curl->option('SSLVERSION', 3);

		return $data = $this->curl->execute();

	}

PHP

dublicate a child table rows and parent table rows mysql [CodeIgniter]


    // call to model to model ...
    public function duplicateTableRecord ($table, $keys = [],$ignore_key) 
    {
       /* generate the select query */
       if (is_array($keys)) {
           foreach ($keys as $key_field => $key_val) {

               $this->db->where($key_field, $key_val); 
           
           }
       }
       // return var_dump($keys);
       $query = $this->db->get($table);
      
        foreach ($query->result() as $row){   
           foreach($row as $key=>$val){        
              if($key != $ignore_key){ 
              /* $this->db->set can be used instead of passing a data array directly to the insert or update functions */
              $this->db->set($key, $val);               
              }//endif              
           }//endforeach
        }//endforeach

        /* insert the new record into table*/
        $this->db->insert($table); 
        return $this->db->insert_id();
    }

    public function duplicateForeignTableRecord ( $table, $foreign_keys_vals = [],$ignore_key,$update_keys_vals = [] ) 
    {
       /* generate the select query */
       if (is_array($foreign_keys_vals)) {
           foreach ($foreign_keys_vals as $key_field => $key_val) {

               $this->db->where($key_field, $key_val); 
           
           }
       }
       // $this->db->where($foreign_key_field, $foreign_key_val); 

       $query = $this->db->get($table);
      
        foreach ($query->result() as $row){   
           foreach($row as $key => $val){        
              if($key != $ignore_key){ 
              /* $this->db->set can be used instead of passing a data array directly to the insert or update functions */
                $this->db->set($key, $val);               
              }
              foreach ($update_keys_vals as $up_f_key => $up_f_val) {
                  if($key == $up_f_key){
                    $this->db->set($key, $up_f_val); 
                  }
              }
              //endif              
           }//endforeach

           $this->db->insert($table);
        
        }//endforeach

        /* insert the new record into table*/
         
        return $this->db->insert_id();
    }

    // call to function to from controller to model class. 134 more words
Programming

Install LAMP server on Ubuntu 16.10

Using following steps we can intall Apache , MySQL and PHP on Ubuntu 16.10 system.

1. First install Apache server

Open Terminal and write following command 477 more words

Php

Photo Collage [PHP]


<?php if (!empty($entry['photos'])) {
?>