Complete Program for adding required attribute, and setting some value in html element using jQuery. <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>Adding Attribute to HTML Element Using jQuery</title> <script src=”https://code.jquery.com/jquery-1.12.4.min.js”></script> <script> $(document).ready(function(){ $(“.add-attribute”).click(function(){ // Setting Checkbox is checked $(‘input[type=”checkbox”]’).attr(“checked”, “checked”); // Setting a test value in textbox $(‘input[type=”text”]’).attr(“value”, “My Name is Shailendra”); }); }); […]
Author: codingadmin
Get Max Id of A Table in Codeigniter : Function / Method <?php // Function for get max id public function get_max_id($table) { $this->db->select_max(‘id’); $query = $this->db->get($table); $res = $query->row(); return $res->id; } ?>
Codeigniter Form Elements
Input Element <?php echo form_input([‘name’ =>’city’, ‘id’ => ‘city’, ‘class’ => ‘form-control’, ‘placeholder’ => ‘City’, ‘value’ => set_value(‘city’)]);?>
<?php if($this->input->post(‘submit’)) { if(!empty($_FILES[“product_image”][‘name’])) { $config = array( ‘upload_path’ => “./uploads/products/”, ‘allowed_types’ => “jpg|jpeg|png|gif”, ‘overwrite’ => TRUE, ‘max_size’ => “2048000”, // Can be set to particular file size , here it is 2 MB(2048 Kb) //’max_height’ => “768”, //’max_width’ => “1024”, ‘file_name’ => time().’-‘.$_FILES[“product_image”][‘name’] ); $uploaderror = ”; $this->load->library(‘upload’, $config); if($this->upload->do_upload(‘product_image’)) { $uploadData = […]
<?php class Loginmodel extends CI_Model { public function login_valid( $email, $password ) { $q = $this->db->where([’email’ => $email, ‘password’ => $password]) ->get(‘users’); if( $q->num_rows() ) { //return $q->row()->id; return $q->row(); } else { return FALSE; } } } ?>
class Login extends MY_Controller { /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * – or – * http://example.com/index.php/welcome/index * – or – * Since this controller is set as the default controller in * config/routes.php, it’s displayed at http://example.com/ * * So any other public […]
Creating a form in Codeigniter, This program will create a form in codeigniter. <?php echo form_open(current_url(), [‘method’ => ‘post’]);?> <div class=”form-group has-feedback”> <?php echo form_input([‘name’ => ‘username’, ‘type’ => ’email’, ‘class’ => ‘form-control’, ‘placeholder’ => ‘Enter email’, ‘value’ => set_value(‘username’)]);?> <span class=”glyphicon glyphicon-envelope form-control-feedback”></span> <?php echo form_error(‘username’);?> </div> <div class=”form-group has-feedback”> <?php echo form_password([‘name’ […]
First create a folder “assets” in main folder for html template’s CSS, JS and Images Paste all css and js files inside assets folder Goto:- application>views> (create a test.php file and paste html code) Open:- Application>config>autoload.php (Pass ‘url’ in helper array) Open:- Application>config>autoload.php (Pass ‘database’,’session’ in libraries array) Write the following code in your test […]
Starting With Codeiginiter
Download and extract codeigniter zip file where you want to start the project. Create an .htaccess file with following content (for removing index.php) RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] Goto:- application>core> (create a controller for having common mehods) – Optional Create and test a function for testing that controller […]
Substraction Program in PHP
This is subtraction program, this will perform subtraction operation using 2 (Two) numbers. <?php $a = 10; $b = 20; $c = $b – $a; echo “Answer: “.$c; ?>