CodeIgniter Forums

Full Version: passing pages_id
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

When someone press this edit button, I expect that it carries me to call a certain database which is the particular data should be retrieve and show it in :

http://127.0.0.1/CompanyGiondaCI/index.p.../editpages

from:

http://127.0.0.1/CompanyGiondaCI/index.php/cpages/pages

I wonder who to transfer and pass the pages_id value to the next page?

Any clue?  Thanks in advance.

views/pages.php


PHP Code:
<div class="row-fluid">
                <
div class="span12">
                    
                    <
button type="button" class="add" onclick="location.href='<?php echo site_url('cpages/addpages'); ?>';">ADD PAGES</button
                    
                    <
div class="widget-box">
                        <
div class="widget-title"><h5>Administrator</h5></div>
                        <
div class="widget-content">
                        
                        <
table border="0" style="width: 100%; height: 90px;">
                            <
tr>
                                <
td>PAGES NAME</td>
                                <
td>CREATE DATE</td>
                                <
td>ORDER</td>
                                <
td>CONTENT</td>
                                <
td>EDIT</td>
                                <
td>DELETE</td>    
                            </
tr>
                            
                            <?
php foreach ($pages as $pages_item): ?>
                            <tr>
                                <td><?php echo $pages_item->pages_name?></td>
                                <td><?php echo $pages_item->create_date?></td>
                                <td><?php echo $pages_item->pages_order?></td>
                                <td><?php echo $pages_item->pages_content?></td>
                                <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editpages'); ?>';">EDIT</button></td>
                                <td><button type="button" class="delete" href="adminform.php">DELETE</button></td>    
                            </tr>    
                            <?php endforeach; ?>
                            
                        </table>            
                        </div>
                    </div>                    
                </div>
            </div> 




controllers/Cpages.php

PHP Code:
public function pages() { 
    
    
        
$data['pages'] = $this->Mpages->call_pages();
            
        
$this->load->view('pages'$data); 
        
    } 
I would like to know when you are going to quit and sit down and read the php manuals, CodeIgniter Users Guide and do Google Searches ?
Never going to happen. He's a lost cause.
(08-09-2016, 11:13 PM)davy_yg Wrote: [ -> ]Hello,

When someone press this edit button, I expect that it carries me to call a certain database which is the particular data should be retrieve and show it in :

http://127.0.0.1/CompanyGiondaCI/index.p.../editpages

from:

http://127.0.0.1/CompanyGiondaCI/index.php/cpages/pages

I wonder who to transfer and pass the pages_id value to the next page?

Any clue?  Thanks in advance.

views/pages.php


PHP Code:
<div class="row-fluid">
                <
div class="span12">
                    
                    <
button type="button" class="add" onclick="location.href='<?php echo site_url('cpages/addpages'); ?>';">ADD PAGES</button
                    
                    <
div class="widget-box">
                        <
div class="widget-title"><h5>Administrator</h5></div>
                        <
div class="widget-content">
                        
                        <
table border="0" style="width: 100%; height: 90px;">
                            <
tr>
                                <
td>PAGES NAME</td>
                                <
td>CREATE DATE</td>
                                <
td>ORDER</td>
                                <
td>CONTENT</td>
                                <
td>EDIT</td>
                                <
td>DELETE</td>    
                            </
tr>
                            
                            <?
php foreach ($pages as $pages_item): ?>
                            <tr>
                                <td><?php echo $pages_item->pages_name?></td>
                                <td><?php echo $pages_item->create_date?></td>
                                <td><?php echo $pages_item->pages_order?></td>
                                <td><?php echo $pages_item->pages_content?></td>
                                <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editpages'); ?>';">EDIT</button></td>
                                <td><button type="button" class="delete" href="adminform.php">DELETE</button></td>    
                            </tr>    
                            <?php endforeach; ?>
                            
                        </table>            
                        </div>
                    </div>                    
                </div>
            </div> 




controllers/Cpages.php

PHP Code:
public function pages() { 
    
    
        
$data['pages'] = $this->Mpages->call_pages();
            
        
$this->load->view('pages'$data); 
        
    } 


I have done some google search and have not find the answer yet about how to passing variables from view to controllers.  I only know how to pass variable from controllers to view.  And hoping to get more guideline to find my way out.
You need to add to the page_id to the URL like this

PHP Code:
<button type="button" class="edit" 
onclick="location.href='<?php echo site_url('cpages/editpages/'.$pages_item->pages_id); ?>';">EDIT</button

Then in the controller method you add an id variable as parameter.
Okay, I just did. Here is my result after typing that codes:


An Error Was Encountered

Unable to load the requested class: Scripto
Hi davy_yg,

I have been reading some of your posts and it is clear that people are getting annoyed with you. You fail to read provided answers  and have very little understanding of PHP. Your knowledge level of HTML and CSS also seems to be little to none.

You do seem eager to build an application using CodeIgniter. But CodeIgniter is not a magic tool that will give you what you need. Without a basic understanding of PHP you will keep asking questions that will get you nowhere on the forum.

Start where we all had to start. READ Documentation!, STUDY!, read books and practice! before you attempt building an application.

And please, please stop asking the forum to build the application for you. Because that is literally what you are doing.

Kind regards,
Martin