CodeIgniter Forums
[SOLVED] Showing Galleries_name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [SOLVED] Showing Galleries_name (/showthread.php?tid=65963)



[SOLVED] Showing Galleries_name - davy_yg - 08-16-2016

GALLERIES NAME:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: views/editgalleries.php
Line Number: 46
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\editgalleries.php
Line: 46
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 348
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once



views/editgalleries.php


PHP Code:
<table>
                    <
tr>
                    <
td><i>GALLERIES NAME: <?php echo $galleries_name?></i></td>
                    </tr>
                    <tr>
                    <td>
                        <br><br>ADD IMAGE<br>
                        <input type="text"></input> 
                        <br><br>
                    </td>
                    
                    <td>
                        <div style="margin-left: 50px; margin-top: 60px;">
                                            
                        <div class="form-group">
                        <div class="row">
                        <div class="col-md-12">
                        
                        <input type="file" name="filename" size="20" />
                        <span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
                        </div>
                        </div>
                        </div>
            
                        
                        <div class="row">
                            <div class="col-md-12">
                                <input type="submit" class="edit" value="Upload Image" class="btn btn-primary"/>
                            </div>
                        </div>
                        </div>
                    </td>
                    </tr>
                    </table> 




controllers/Cpages.php


PHP Code:
public function editgalleries() { 
    
        
$id $this->uri->segment(3);
    
        
$data['galleries_name'] = $this->Mpages->edit_gallery($id);
    
        
$this->load->view('editgalleries'$data); 
        
    } 


models/Mpages.php


PHP Code:
    public function edit_gallery($id)
    {
        
$this->db->where('galleries_id'$id);
        
$query $this->db->get('galleries');
        return 
$query->result_array();
        
    } 



RE: Showing Galleries_name - JayAdra - 08-17-2016

Can someone just ban him? Most of his issues aren't CI related and he doesn't seem interested in doing anything to solve his own problems.


RE: Showing Galleries_name - ivantcholakov - 08-17-2016

@JayAdra

+1


RE: Showing Galleries_name - albertleao - 08-17-2016

(08-17-2016, 12:30 AM)JayAdra Wrote: Can someone just ban him? Most of his issues aren't CI related and he doesn't seem interested in doing anything to solve his own problems.


I've thought about this too, but he'd just create another account and continue posting this stuff. I've just resorted to linking him to the php.net site.


RE: Showing Galleries_name - wolfgang1983 - 08-17-2016

(08-16-2016, 09:47 PM)davy_yg Wrote: GALLERIES NAME:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: views/editgalleries.php
Line Number: 46
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\editgalleries.php
Line: 46
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 348
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once



views/editgalleries.php


PHP Code:
<table>
                    <
tr>
                    <
td><i>GALLERIES NAME: <?php echo $galleries_name?></i></td>
                    </tr>
                    <tr>
                    <td>
                        <br><br>ADD IMAGE<br>
                        <input type="text"></input> 
                        <br><br>
                    </td>
                    
                    <td>
                        <div style="margin-left: 50px; margin-top: 60px;">
                                            
                        <div class="form-group">
                        <div class="row">
                        <div class="col-md-12">
                        
                        <input type="file" name="filename" size="20" />
                        <span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
                        </div>
                        </div>
                        </div>
            
                        
                        <div class="row">
                            <div class="col-md-12">
                                <input type="submit" class="edit" value="Upload Image" class="btn btn-primary"/>
                            </div>
                        </div>
                        </div>
                    </td>
                    </tr>
                    </table> 




controllers/Cpages.php


PHP Code:
public function editgalleries() { 
    
        
$id $this->uri->segment(3);
    
        
$data['galleries_name'] = $this->Mpages->edit_gallery($id);
    
        
$this->load->view('editgalleries'$data); 
        
    } 


models/Mpages.php


PHP Code:
    public function edit_gallery($id)
    {
        
$this->db->where('galleries_id'$id);
        
$query $this->db->get('galleries');
        return 
$query->result_array();
        
    } 

You need to have it in foreach loop because the result is in an array

Code:
<?php foreach ($galleries_name as $gallery) {?>
<img src="<?php echo $gallery['image'];?>" >
<?php }?>


If you are building a online shop I would watch https://www.youtube.com/watch?v=am_di0HfnzI

Or

Use www.opencart.com it will save you asking a whole lot of questions


RE: Showing Galleries_name - davy_yg - 08-17-2016

Appologize all. I've found answer to these question. I'll marked it solved.


RE: Showing Galleries_name - albertleao - 08-17-2016

(08-17-2016, 07:21 PM)davy_yg Wrote: Appologize all.  I've found answer to these question.  I'll marked it solved.

Can you try to do some research before posting basic debug errors on this forum?