php - Change main view position codeigniter

899

I have some problem with position off my tables.

here you can see what is looking now:

http://postimg.org/image/auv0lum57/

My controller:

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

class Manage_products extends CI_Controller {

public function __construct()
{
    parent::__construct();


    $this->load->model('Products_model');
    $this->load->library('form_validation');
}

public function index()
{
    session_start();

    $this->data['products'] = $this->Products_model->get_all();
    $this->data['title'] = 'Product Management';

    $this->data['message'] = $this->session->flashdata('message');
        $this->load->view('main_view', $this->data);
    $this->load->view('manage_products', $this->data);

}  

view off manage_products Products table, td, th { border:1px solid green; } th { background-color:green; color:white; }

        #infoMessage p{
            padding: .8em;
            margin-bottom: 1em;
            border: 2px solid #ddd;
            background: #FFF6BF;
            color: #817134;
            border-color: #FFD324;
            text-align: center;
        }
        </style>
        </head>
        <body>
        <table width="700" border="0" align="center">
            <tr>
                <td><h2>Parduotuvės </h2></td>
            </tr>
            <tr>
                <td><div id="infoMessage"><?php echo $message;?></div></td>
            </tr>
            <tr>
                <td><input name="New" type="button" value="Pridėti naują" onclick="window.location='product/add'" /></td>
            </tr>
        </table>
        <form name="frmproduct" method="post">
            <input type="hidden" name="rid" />
            <input type="hidden" name="command" />
            <table width="700" align="center">
                <tr>
                    <th width="150"><strong>Parduotuvės pavadinimas</strong></th>
                    <th><strong>Prekės identifikatorius</strong></th>
                    <th><strong>Nuoroda</strong></th>
                    <th><strong>Redaguoti</strong></th>
                    <th><strong>Ištrinti</strong></th>
                </tr>
                <?php
                foreach ($products as $product){
                    $product_id = $product['id'];
                ?>
                    <tr>
                        <td><?php echo $product['pavadinimas'] ?></td>
                        <td><?php echo $product['prekesid'] ?></td>
                        <td><?php echo $product['linkas'] ?></td>
                        <td><a href='product/edit/<?php echo $product_id ?>'>Redaguoti</a></td>
                        <td>
                            <?php 
                                echo anchor('product/delete/'.$product_id, 'Delete', array('onClick' => "return confirm('Ar tikrai norite ištrinti?')"));
                            ?>
                        </td>
                    </tr>
                <?php
                }
                ?>
            </table>
        </form>
        </body>
        </html>

I think problem is with line 22. I must load main_view, but my table must be in main_view, not in bottom. How to fix this problem?

281

Answer

Solution:

I think I under stood correct try something like

return $this->load->view('name', null, true) or $this->load->view('name', $data, true)

could try and use null or true, return for tables.

People are also looking for solutions to the problem: php - MySQL Syntax Error

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.