Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14343 articles
Browse latest View live

Values from textbxx array not updating

$
0
0
Hi guys, Im new in this forum and i'm having a hard time updating selected value from checkbox coming from the textbox value. 

Scenraio:

I want to update selected items, For example I want to update Item-2 and the textbox from item recieve will be enable, I will enter a number for example 1 and the textbox from total receive will automatically sum using ajax.

The problem is after submiting the value from total recieve the records that was updating is blank, but when I try to check and print_r the value is there.

And one more thing if all checkbox are all checked and enter a number for each item recieve, the value that it only get is the last value and will be updated will all selected checkbox.

Note: 
Checkbox is an array
Textbox from total recieve is an array


Can you guys please help me?

Here's my UI:

[Image: w5jkp.jpg]

Here's my code.

Controller:
Code:
public function recitem_insert(){

$this->load->model('dbquery');    

$check = $this->input->post('check');    
$total_rec = $_POST['total_rec'];

    
if(isset($check)){ //Check if check is checked    
        
  for($i=0;$i<sizeof($check);$i++){
    for($j=0;$j<sizeof($total_rec);$j++){    

    $updateData = array('rec_qty' => $total_rec[$j] );                                                        
    $this->dbquery->modUpdatedynamicval('tblstock', 'id', $updateData, $check[$i]);

       }        
   }//end for loop    

    echo "<script type='text/javascript'>
        alert('Successfully Added!');
        window.close();
        </script>";        
    
}else{ //End If
      echo 'Please select a checkbox';
    }

}


View:

Code:
<form method="post" action="<?php echo base_url() ?>user/recitem_insert">

<div class="box">
<div class="box-header">
<h3 class="box-title">System ID: <b><?php echo $process_id; ?></b></h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Action</th>
<th>Item Code</th>
<th>Item Description</th>
<th>Required QTY Order</th>
<th>Last QTY Recieve</th>
<th>Item Recieve</th>
<th>Total Recieve</th>



</tr>
</thead>
<tbody>

<?php                  

$query = $this->db->query("SELECT * FROM tblstock where process_id = '$process_id'");
foreach ($query->result() as $row){                                      
?>  

<tr>
<td><input type="checkbox" name="check[]" id="opt" value="<?php echo $row->id; ?>" onclick="valueChanged()"> </td>
<td><?php echo $row->item_code; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo $row->qty_order; ?></td>
<td><?php echo $row->rec_qty; ?></td>

<input type="hidden" name="last_item_rec[]"  value="<?php echo $row->rec_qty;  ?>">

<td><input type="text" name="item_rec[]"  id="txt" disabled=""></td>  
<td><input type="text" name="total_rec[]"></td>  


</tr>

<?php

}
?>  

</tbody>
<tfoot>

</tfoot>
</table>
</div>
<!-- /.box-body -->
</div>

<div class="box-footer">
<button type="submit" class="btn bg-olive btn-flat margin">Submit</button>
</div>

</form>


Model:

Code:
public function modUpdatedynamicval($table, $column, $data, $equal_to){
        
$this->db->where($column, $equal_to);
$this->db->update($table, $data);         
    
}


Any help will be gladly appreciate.


Thank you..

Free Video tutorial this month!

$
0
0
Hey gang - it's coming up on my birthday so I wanted to do something special, so I'm giving away this month's video tutorial for free, whether you're a patron or not.

The video covers the new testing tools included in CodeIgniter 4 that are there to help you test all areas of your application. In addition to normal PHPUnit test case, CI4 includes new database tools specific for testing, the ability to test your Controllers in isolation, and the ability to test entire endpoints of your application. The view gives a quick overview of the features so that you know what's available and where they might be useful.

If you're new to testing your application, the time has never been better to get started with it.

If you like this video please consider becoming a patron at any of the different tiers.

Enjoy!

Oh! I'll be doing another freebie tutorial in the next week or so and want to know, what do you guys want to know about?

OOP Concept PHP

$
0
0
As a first learner of programming how to learn a PHP in OOP Concept

Should I understand  about logic, aritmethic, assingment concept, as I know PHP Native is used OOP Concept not MVP Concept


Now, I use Visual Studio Code in New Version 1.31,

What is the step to undertand OOP Concept in PHP ?

Rest api

$
0
0
Is it secure to use restapiserver from github to write rest api using codeigniter..?

upgrade to 3.00

$
0
0
I am trying to upgrade to version 3.0.0.  It is giving a 404 when I try and access the site. Version 2.2.6 was ok.


I have

$route['default_controller'] = "home";

$route['404_override'] = '';


Which hasn't been changed





home.php under application contains



<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
    function index()
    {
        redirect("step/select-type");
    }
}




Any idea what is wrong please

Thanks

500 messages

$
0
0
Is there a way of displaying what 500 message error are in Codeignitor rather than just saying error 500?

How to package original libraries

$
0
0
Hi there! Long time lurker and avid CI user since 2.0. I’ve been diving into CI4 recently, and I’m very excited for it! I have a series of five “zero conf” libraries that I wrote and use in almost every CI3 project I’ve ever done. I never released them (though I intended to) but now with the new version coming soon I’m interested in rewriting them and releasing them as CI4 libraries. I’ve already done the first one (Asset loader). I’m ready to test Composer autoload integration but I’m stumped where to start.

I’m hoping someone can recommend a good resource or example repo where I can learn what additional files I need to include to make my source (includes library, config, & helper) Composer-ready? And tips for making it a happy automagic service (it already is when copied into /app but I want it to work on install from /vendor as well)?

How to show date rows equals current date?

$
0
0
We have a human resource management system that need some modifications. I'd like to show all personnel on leave using the date stamp.
PHP Code:
<?php
                                    $link 
mysqli_connect("localhost""root""""ihrmis");
                                    
$result mysqli_query($link"select COUNT(employee_id) AS count FROM ats_leave_apps WHERE DATE('M Y') = CURDATE()");
                                    
                                    if(!
$result) {
                                        die(
'Error: 'mysqli_error($link));
                                    } else {
                                        
$num_rows mysqli_fetch_assoc($result);
                                        echo 
$num_rows['count'];
                                    }
                                    
?>

Below is the structure of our table where to get those datas

.png   sample.png (Size: 47.9 KB / Downloads: 8)

We want that if the date rows equal to the current date it will show in the dashboard of our system. I hope some generous hearts to help us. Thanks in advance.

Where do I learn about CodeIgniter core (I mean the 'system' folder)?

$
0
0
Hey,

I'm wondering if there is any documentation about CI core itself. Any information architecture, flowcharts or something that gives a glimpse of how the CI works under the hood.

Thanks

hello

$
0
0
My name is ritu, 
happy  after joining this community

CodeIgniter 4.0.0-beta.1 Released

$
0
0
CodeIgniter-4.0.0-beta.1 launches today [Image: smile.gif]

This is a pre-release of 4.0.0. It is not suitable for production! (but it is pretty darn close)

Release highlights:
  • New View Layouts provide simple way to create site site view templates.
  • Fixed user guide CSS for proper wide table display
  • Converted UploadedFile to use system messages
  • Numerous database, migration & model bugs fixed
  • Refactored unit testing for appstarter & framework distributions
     
New messages:
  • Database.tableNotFound
  • HTTP.uploadErr...

App folder changes:
  • app/Config/Cache has new setting: database
  • app/Views/welcome_message has logo tinted
  • composer.json has a case correction
  • env adds CI_ENVIRONMENT suggestion

Check the changelog for details, and the installation writeup for further directions.

We expect 2-3 beta rounds, as we continue to fix remaining bugs and tighten up the code.
We don't plan any official release on April 1st, just so you know Smile
Thank you to the community for stepping up to help make this the best PHP framework!

Do NOT post support questions or feature requests in response to this thread - those will be deleted. We are trying to make the best of the limited resources that we have!

Thank you, and ENJOY!

How to setup your codeigniter projects

$
0
0
How do you guys arrange/structure your projects?

How do you guys structure your controllers? 

how do you separate your functions into specific controllers?

For example: login,logout,register functions should go inside accounts controller.

Let's say i want to make an online shopping web app using codeigniter.

Therefore i will have browse_items function and create_item.

The former doesnt need a logged in account but the latter needs an authenticated account.

Do i then make 2 versions of item controller and put them in separate subfolder inside my controller folder named private/public?

Memory consumption bug

$
0
0
Hi all- I've tested this as thoroughly as I can and continue to be baffled where the buildup is coming from. If anyone wants to recreate or make suggestions please do. Note: I have already worked around this, but would like to determine if this is a framework issue so it gets addressed.

I am using a custom CLI command (App\Commands) to import a large CSV into the database. The actual processing is very simple, and uses existing models (with internal commands only, no modification) to save to the database. After processing a reasonable ~200k lines the script crashes with "Allowed memory size ... exhausted". However, there should be no accruing memory storage as all the variables are reused on each iteration. I suspect something in the model is hanging onto a variable by reference such that it doesn't get cleared on each iteration.

Here's a generalized (but still accurate) version of the code:

PHP Code:
public function run(array $params)
{
    
$myModel = new MyModel();
    
$myModel2 = new MyModel2();
    
    
$file "data.csv";
    
$row 0;
    
    if ((
$handle fopen($file"r")) !== false):
    
        while ((
$data fgetcsv($handle1000",")) !== false):
            
$row++;
            
/* VALIDATE DATA */
            // validate line
            
$num count($data);
            if (
$num != 4):
                
CLI::write("Invalid number of columns on line {$row}: "CLI::color(implode(","$data), 'yellow'));
                return;
            endif;
            
            
// get the timestamp
            
if ($timestamp strtotime($data[2])):
            else:
                
CLI::write("Invalid timestamp on line {$row}: "CLI::color($data[2], 'yellow'));
                return;
            endif;

/* PRIMARY ENTRY */            
            // build the row
            
$row = [
                
'source' => "import",
                
'created_at' => date("Y-m-d H:i:s"$timestamp)
            ];
            
            
// add to the database
            
$myModel->save($row);
            
$ref_id $myModel->getInsertID();

/* DEPENDENT ENTRY */            
            // build the row
            
$row2 = [
                
'ref_id' => $ref_id,
                
'content' => $data[1],
            ];
            
$myModel2->save($row2);

        endwhile;
        
        
fclose($handle);
    endif;

Should i wait for production release?

$
0
0
As the title says, I am starting a new project it's like a multi-author blog.

So, I was thinking to use the latest CodeIgniter 4 beta release to get all the new perks and in future, I don't have to migrate from ci 3 to ci 4.

Migrating from CI 3 to CI 4 is nearly impossible so my question is can I easily migrate from CI 4 beta release to final release?

insert_batch not insert data

$
0
0
Hi all,
I'm new to code igniter but I love it Smile
I have issue with insert_batch, when I try to save multiple row the script no save data

The array:

Code:
Array ( [0] => Array ( [company_name] => thename0 ) [1] => Array ( [company_name] => thename1 ) [2] => Array ( [company_name] => thename2 ) [3] => Array ( [company_name] => thename3 ) )


The controller:

PHP Code:
       public function index()
 
       {
 
               $this->load->helper('file');
 
               $json read_file('./myfile.json');
 
               $obj json_decode($json);
 
               $data['json'] = $obj;
 
               foreach ($data['json']->res as $val
 
               {
 
                       $batch[] = array(
 
                                       'company_name' => $val->res->company_name
                                        
                                
);
 
               }
 
               $this->my_model->get_json_file($batch);

 
       


The model:

PHP Code:
   public function __construct()
 
   {
 
           $this->load->database();
 
   }
 
   public function get_json_file($data)
 
     
        $this
->db->insert_batch('my_table'$data);
 
   


I have not error message in the page but data not present in the DB.


Confused

Question about date helper

$
0
0
Hi there,

I just look through CI4 code, and when I look at date_helper->now function, I'm not quiet sure what is the scenario to use this function.

From what I can see, this function will return a timestamp for a given timezome

but AFAIK timestamp is timezone unrelated, no matter which timezone you are, if you query the timestamp at same time (synced action), you get the same timestamp.

If I misunderstand this function, please let me know.

How to use xdebug instead of CI4 built-in debugging?

$
0
0
As the title.

I use php7.3.1 and xdebug2.7 in some hosting,

How to use Xdebug instead of CI4 built-in debugging?

Thank you for your help.

$this->load->library('email') version codeigniter 3.1.10,

$
0
0
i have this problem, when I add this code:

$configEmail = array(

'protocol' => 'mail',
'smtp_host' => 'mail.**********.com',
'smtp_port' => 25,
'smtp_user' => 'no_repley@*******.com',
'smtp_pass' => *******,
'mailtype' => 'html',
'charset' => 'utf-8',
'newline' => "\r\n"

); 

$this->email->initialize($configEmail);
$this->email->from('no_repley@*******.com', '****.');
$this->email->to('**********@*******.com');
$this->email->subject('hi');
$this->email->message('Saludos');


the server sends me the next warning

"Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request."


The problem is my code or I have to do something on the server?

formerly, after the problem I use 

$this->email->send()

and helping me to solve the problem.

thanks and regards

controller redirects to same page and creates a page inside a page

$
0
0
Hi!
I'm having a strange issue. My page is essentially several forms on the same page but when one form is completed and I do everything I need on the backend, I use redirect(base_url('dashboard')) but it creates the same page on top of the page that was already there. So If I scroll down, I can see the same page (although broken because of javascript stuff)
Has anyone dealt with this issue? I've never done a single page site before. I appreciate any feedback! let me know if you want to see the code.

Codiginiter Sqlsrv

$
0
0
Hi,

I'm getting that standard error that happens when there's something wrong with the sqlsrv driver specifications.

PHP Version 7.3.0

php.ini
Registered PHP Streams
php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar, sqlsrv


A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: E:\[project_folde]\[project_name]\system\database\DB_driver.php
Line Number: 125

$active_group = 'default';

$active_record = TRUE;





$db['default'] = array(

    'dsn'    => '',

    'hostname' => 'DESKTOP-NDT1I0K\SQL2008E', // for example 'cmms-server\SQLEXPRESS' 

    'port' => '1433',

    'username' => 'sa',

    'password' => '[password]',

    'database' => '[database]',

    'dbdriver' => 'sqlsrv',

    'dbprefix' => '',

    'pconnect' => FALSE,

    'db_debug' => (ENVIRONMENT !== 'production'),

    'cache_on' => FALSE,

    'cachedir' => '',

    'char_set' => 'utf8',

    'dbcollat' => 'utf8_general_ci',

    'swap_pre' => '',

    'encrypt' => FALSE,

    'compress' => FALSE,

    'stricton' => FALSE,

    'failover' => array(),

    'save_queries' => TRUE
);

In codeigniter  folder    \system\database\drivers\sqlsrv
file sqlsrv_driver.php line 89
I change
function db_pconnect()
{
return $this->db_connect(TRUE);
}


Any advice from other masters? Thank you.
Viewing all 14343 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>