Welcome Guest, Not a member yet? Register   Sign In
[Problem] HTML Table Class
#11

[eluser]Sein Kraft[/eluser]
Ouch x3!

That was the error.

Tanks inparo

So...another question xD

I cant find the way to send to te controller another return

Code:
$source = $row['file_source'];

I've tried with arrays without luck =(
(same model above)
#12

[eluser]Sumon[/eluser]
Paste your controller and model here. and please mention which value would you like to return from model to controller.
#13

[eluser]Sein Kraft[/eluser]
Code:
function view($data)
    {
        $id = $data['id'];
        
        $query = $this->db
        ->select('id, user_id, file_name')
        ->from('imageboard_image')
        ->where($id)
        ->get();
        
        if ($query->num_rows() > 0)
          {
            $rows = $query->result_array();
            foreach($rows as $row):
            $image = '<img src="http://127.0.0.1/CI/images/'.$row['file_name'].'" title="'.$row['id'].'" >';
            $source = $row['source'];
            endforeach;
            return $image;
          }
          else
          {
        return false;
          }
    }

The same code but i need retrieve also $source
#14

[eluser]Sumon[/eluser]
In a second i can say there is a way
Code:
foreach($rows as $row):
   $image = '<img src="http://127.0.0.1/CI/images/'.$row['file_name'].'" title="'.$row['id'].'" >';
   $source = $row['source'];
   $my_data[]=array('image'=>$image,'source'=>$source);
endforeach;
return $my_data;
in controller
$data['content'] = $this->model_name->model_method();
and in view you will receive
Code:
$content['image'];
$content['source'];
Let me know is it works for you?
#15

[eluser]Sein Kraft[/eluser]
Not work =(

PD: I'm using Template parser class.

The actual controler:
Code:
function view($id)
    {    
        $this->load->model('model_imageboard','', TRUE);
        $this->model_imageboard->view($id);
        $file_data['content'] = $this->model_imageboard->view($id);
        $data = array(
                'view_heading' => 'Heading',
                'link_edit' => '<a href="../edit/'.$id.'">Edit</a>',
                'link_report' => '<a href="../report/'.$id.'">Report</a>',
                'link_favorite' => '<a  href="../favorite/'.$id.'">Add</a>',
                'link_download' => '<a  href="../download/'.$id.'">Download</a>',
                    
                'view_image' => $content['image'],
                'view_source' => $content['source']
                     );

        $this->parser->parse('view_imageboard_view', $data);

    }

Te actual model:
Code:
function view($id)
    {
        $query = $this->db
        ->select('id, user_id, file_name, file_height, file_width, file_source')
        ->from('imageboard_file')
        ->where('id', $id)
        ->get();
        
        if ($query->num_rows() > 0)
          {
            $rows = $query->result_array();
            foreach($rows as $row):
            if ($row['file_height'] < 600 && $row['file_width'] < 600)
                {
                    $image = '<img class="image_border" src="http://127.0.0.1/CI/'.$row['file_name'].'" >';
                }
            else
                {
                    $image = '<img class="image_border" src="http://127.0.0.1/CI/med_'.$row['file_name'].'" >';
                }
            $source = $row['source'];
            $file_data[]=array('image'=>$image,'source'=>$source);
            endforeach;
            return $file_data;
          }
          else
          {
        return false;
          }

The view:
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;image&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<br>
<div id="body_container">
<div class="image_block">
{view_image}
<br>
{view_source}
<div class="image_menu">
<div id="ver_menu">
        <ul>
            <li>{link_edit}</li>
            <li>{link_report}</li>
            <li>{link_favorite}</li>
            <li>{link_download}</li>
        </ul>
</div>
</div>
</div>
{link_prev}{link_next}
<br>
<br>
</div>
&lt;/body&gt;
&lt;/html&gt;
#16

[eluser]Sumon[/eluser]
Sorry to say, i have never used CI templating. Someone other help you surely. Smile
#17

[eluser]Pascal Kriete[/eluser]
This isn't too hard, but I'm a little foggy at what you're trying to achieve at this point. It has certainly strayed away from the initial problem of generating an HTML table, which is fine, but it's a little hard to follow.

In the controller and view it looks like you're trying to get one image. In the model you're looping, so that would mean it's more than one.

One or many? Once we have that out of the way it's pretty straight forward Wink .




Theme © iAndrew 2016 - Forum software by © MyBB