Welcome Guest, Not a member yet? Register   Sign In
ID doenst work..
#1

[eluser]Zimooon[/eluser]
Hey guys,

in my controller i got those 2 functions:

Code:
function showfolder()
     {
  
     $data = array();

        
        $data['folders'] = $this->folder_model->getFolder();
        $this->load->view('auth/folderlist', $data);
        $this->data['title'] = "Bilderordner";
   }
  
  function showimage()
    {
    
    $data = array();
      
        $folderx = $this->input->post('folderx');
        $data['images'] = $this->image_model->getImages();
        $this->load->view('auth/imagelist', $data , $folderx);
        $this->data['title'] = "Bilder";  
        
    }

here is the view for showfolder:
Code:
<th class="thAktion">Aktion</th>
                        </tr>&lt;?php foreach($folders as $folders_row): ?&gt;  
                         <tr class="&lt;?php echo alternator('even', 'odd');?&gt;">
                            <td>&lt;?php echo $folders_row['id'];  ?&gt;
                                    
<a name="folderx" id="folderx" href="/upload/showimage/">&lt;?php echo $folders_row['foldername']; ?&gt; </a> //* this line is important *//

                                      &lt;?php echo $folders_row['tag'];
                                    
                                 ?&gt;
                            
                            </td>

and here is the view of showimage:
Code:
</tr>&lt;?php foreach($images as $images_row): ?&gt;  
                        
                         <tr class="&lt;?php echo alternator('even', 'odd');?&gt;">
                            <td>&lt;?php if($images_row['folder'] == 'folderx' ):?&gt;
                            <img src="&lt;?php echo $images_row['imagepath'];?&gt;">
                                    
                              
                            
                            </td>
                        
                          </tr>
                                             &lt;?php endif;?&gt;
                           &lt;?php endforeach ?&gt;

So as you maybe see i have folders which are stored in a DB.
They are echoed in showfolder and are linked to showimage.
I want that the link i click (f.e. Folder1) all images with 'folder == Folder1 are shown.
Whats the problem? folderx get the input and the a href hast the id/name foldex .
When i change
Code:
&lt;?php if($images_row['folder'] == 'folderx' ):?&gt;
to
Code:
&lt;?php if($images_row['folder'] == 'folder1' ):?&gt;
all images in folder1(have db tag folder1) are shown and no others in DB.

Please helpSmile

have a nice day
#2

[eluser]MathBoon[/eluser]
It'be nice if you could format your code in a way that is more readable.

I don't really get what you're doing there, but you can't use the name or id of your link when submitting your form.

Code:
<a name="folderx" id="folderx" href="/upload/showimage/">&lt;?php echo $folders_row['foldername']; ?&gt; </a>
//* this line is important *//

What is it that you need in your showImage function, an ID or just the folderName?
I assume it's the name, so you could do it like this:

Code:
<a href="/upload/showimage/&lt;? echo $folders_row['foldername']; ?&gt;">
&lt;?php echo $folders_row['foldername']; ?&gt;
</a>

And in your controller you'd have to use the $_GET var like this:

Code:
function showimage($folderX)
{
    $data = array();
      
    $data['images'] = $this->image_model->getImages();
    $this->load->view('auth/imagelist', $data , $folderx);
    $this->data['title'] = "Bilder";  
        
}
#3

[eluser]Zimooon[/eluser]
edit:

thank you ! this works fine.

have a nice day




Theme © iAndrew 2016 - Forum software by © MyBB