Welcome Guest, Not a member yet? Register   Sign In
  Views and output in a foreach
Posted by: El Forum - 08-28-2007, 10:10 AM - No Replies

[eluser]Unknown[/eluser]
Hello everybody !

Well, I'm a new user with CI but with the docs I use CI in a good way, with the MVC approach and other useful things.

But I have a problem with a view and particularly with the TRUE/FALSE option like this: $this->load->view('file_name', $data, true/false) (see http://ellislab.com/codeigniter/user-gui...oader.html for details)

The facts :

My controller calls a view called results, which loads normally.

In this view, there is a foreach like this :

Code:
// [...] html and php code before [...]

            foreach($goods as $item) {

                $data['name'] = '<img src="'.base_url().'l/'.$item['id'].'.png" /><br /> <b>'.$item['value'].'</b>';
                
                $data['desc'] = $this->load->view('quiz/description', $item, TRUE);

                $this->load->view('quiz/form', $data);
            }

// [...] html and php code after [...]

As you can see, there are 2 others views in this code.

The first, the description view is a very small file with gives a little line of HTML code.

This code is put in the $data array.

This array is passed to the form view. And this last view echoes the final result.


Well, that were the facts, now the problem :

The first item of the foreach is done normally. The description is inside the form view.

But the problem comes after the first one, the description echoes before the form view. Like there were no TRUE option at this line : $this->load->view('quiz/description', $item, TRUE);

Is there a solution ? An error in my code ? A output cache problem ? Is that a good view approach too ?

Thanks Smile

PS : sorry for my english, that isn't my first language.


  ajax and database access
Posted by: El Forum - 08-28-2007, 09:45 AM - No Replies

[eluser]GSV[/eluser]
I have used aculo (ajax) script and it call http://127.0.0.1/rmb/db.php php script not connected at all to project, just alone script. I need use CodeIgniter database layer into this script. How to initialize database class?
Thanks for answers and advice.

Code:
&lt;select onchange="setSelected()" id="select_state" name="select_state" title="Select state" class="srchselect"&gt;
        <option value ="0">Select state</option>
        &lt;?php foreach($states as $item):?&gt;
            <option value ="&lt;?=$item['id'];?&gt;">&lt;?=$item['cat_title'];?&gt;</option>
        &lt;?php endforeach;?&gt;
    </select>
    &lt;input type="text" name="search_word" id="search_word_id" class="srchinput" &gt;<div id="live_search" style="display:none;border:1px solid black;background-color:white;position:relative;"></div>

    
        // <![CDATA
            function setSelected() {
                new Ajax.Autocompleter('search_word_id','live_search','http://127.0.0.1/rmb/db.php',{ tokens: ',', frequency: 0.4, minChars: 2, parameters: 'state='+document.getElementById('select_state').options[document.getElementById('select_state').selectedIndex].value });
            }
        // ]]>


  Pagination tutorial -> i`m needing help!
Posted by: El Forum - 08-28-2007, 08:54 AM - No Replies

[eluser]rafael apocalypse[/eluser]
Hello!

I'm trying to use pagination in my app. But just with the user guide, I couldn't find how to set it up.

In my controller I have this code

Code:
//Load the CI LIbraries we need for this functuon
      $this->load->library('table');
      $this->load->library('pagination');
      
          $this->load->model('admin/dominio');
          $dominios = $this->dominio->get_pai();
      
      $rows = $dominios['num_rows'];
      
      //Config for Pagination including getting the total number rows in DB
      $config['base_url'] = base_url().'admin/dominios/index/';
      $config['total_rows'] = $rows;
      $config['per_page'] = '25';
      $config['uri_segment'] = '3';
      $config['num_links'] = '2';
      $this->pagination->initialize($config);
      
            $output = "<table>
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>área temáticas</th>
                                            <th>filhos</th>
                                            <th>traduções</th>
                                            <th>traduzir</th>
                                            <th>termos</th>
                                            <th>ver +</th>
                                            <th>editar</th>
                                            <th>excluir</th>
                                        </tr>
                                    </thead>
                                    <tbody>";
            //contador para efeito zebra
            $counter = 0;
            foreach($dominios['result'] as $dominio):

                //lista as subcategorias
                $id = $dominio->id_dominio;
                $filhos = $this->dominio->get_child($id);

                //lista a quantidade de termos em um domínio
                $this->load->model('admin/termo');
                $termos = $this->termo->count_termos($id);

                $traducoes = $this->dominio->traducoes($id);

                if($counter == 0): $class = 'class="odd"'; $counter++; else: $class = 'class=""'; $counter = 0; endif;
                $output .= "<tr ".$class.">";
                    $output .= "<td>".$dominio->id_dominio."</td>";
                    $output .= "<td>".$dominio->dominio."</td>";
                    $output .= "<td>".$filhos['rows']."</td>";
          $output .= "<td>".$traducoes."</td>";
          $output .= "<td>".anchor('admin/dominios/traduz/'.$id, 'traduzir')."</td>";
                    $output .= "<td>".$termos."</td>";
                    $output .= "<td>".anchor('admin/dominios/vermais/'.$id, 'ver +')."</td>";
                    $output .= "<td>".anchor('admin/dominios/edit/'.$id, 'editar')."</td>";
                    $output .= "<td>".anchor('admin/dominios/del/'.$id, 'excluir')."</td>";
                $output .= "</tr>";
           endforeach;
            $output .= "</tbody>
                            </table>";
                            
            $output .= $this->pagination->create_links();

            return $output;

in this controller I use a model to get some data from db. Well the pagination are being made ok, but it doesn't work.

My model are
Code:
function get_pai(){
            $this->db->where('father is null');
            $this->db->where('original', 0);
            $query = $this->db->get('dominio');
            $result['result'] = $query->result();
      $result['num_rows'] = $query->num_rows();
      
            return $result;
        }

Is there anybody who can help me, or send me a real tutorial on pagination with CI?

Thanks

RA


  Passing values from mysql to email class
Posted by: El Forum - 08-28-2007, 07:30 AM - No Replies

[eluser]zimi[/eluser]
I am having problems sending out email if I pass values to the class which are coming from an mysql table. If I change the values to a string "value" it works however if I pass it via $stringname it does not work.

Can someone please help me identify what I am doing wrong.

Thanks ../zimi


  Need Help on Sessions , Security , Tag Cloud , Caching ..!!
Posted by: El Forum - 08-28-2007, 07:18 AM - No Replies

[eluser]santosh[/eluser]
Hi all,

I am very new to CI. I have worked out basic samples. Now i want to know how to
do session handling, security , tag clouding, caching (prefereably with memcache )

Any pointers would be helpful & the pros & cons that helps in making a better choice..!

Thanks,
SK


  Using MySQL blobs -- CI vs php mysql functions
Posted by: El Forum - 08-28-2007, 06:38 AM - No Replies

[eluser]fMertins[/eluser]
Hi,

I´m saving blobs in MySQL, and I´m afraid that doesn´t works when using the database class from CI. I´ve made one example using CI methods and other example using MySQL php functions, here are the files:

BLOB ok
BLOB not ok

It seems CI database do a kind of convertion or translation characters...

Here is the code from BLOB ok

Code:
public function upd(Categoria $cate) {
      $upd = "update categoria set imagem_barrinha = '" . $cate->imagemBarrinha . "' where codcategoria = " . $cate->codCategoria;
      $bdok = mysql_query($upd);
      
      $dbMysql = mysql_connect("127.0.0.1", "root", "...");
      mysql_select_db("benklin", $dbMysql);
  
      if (!$bdok) {
         die("Erro ao alterar cliente. Comando SQL: " . $update);
      }
   }

And here is the code from BLOB not ok
Code:
public function upd(Categoria $cate) {
      $dados = array(
      "imagem_barrinha" => $cate->imagemBarrinha,
      );
      
      $this->db->where("codcategoria", $cate->codCategoria);
      $this->db->update("categoria", $dados);
   }

I´m missing something when using CI database, or doing something wrong?
Thanks!


  CI constant in JS script
Posted by: El Forum - 08-28-2007, 05:00 AM - No Replies

[eluser]obiron2[/eluser]
I'm making increasing use of Ajax and would like to maintain use of full URIs in Ajax calls. What is the best way of setting base_url() and site_url() in JS.

FYI all of my JS is in a separate script file and so is not dynamic.

If I sent a small script as part of the main page header

Code:
print "#script# var BaseURL = ".base_url().";";
print  "var SiteURL = ".site_url()."; #/script#";

would this then be available to the JS file as a global variable, or is there a more elegant solution.

Obiron


  CRUD and one to many relation
Posted by: El Forum - 08-28-2007, 04:18 AM - No Replies

[eluser]abmcr[/eluser]
What is the best way with CI for managing , in an admin back end, table with the relation one to many?
I use with satisfaction the Rapyd library, (specialy the iframe field is very useful and fast to use) but do you know other simple and rapid (! ;-) ) methods? Thank you

Ciao

Andrea - ITALY


  Is there any native method for counting queries made?
Posted by: El Forum - 08-28-2007, 03:10 AM - No Replies

[eluser]#1313[/eluser]
I found the {elapsed_time} variable very useful and now i'm wondering if there is something like {queries_used} to see the number of queries it took to load the page. Or is there another method for counting queries done?


  cutted post array from the form
Posted by: El Forum - 08-27-2007, 11:17 PM - No Replies

[eluser]EugeneS[/eluser]
Hello,

any ideas what maight be wrong or on what it is depend ?

so in the form i add dynamically input elements with the name FormElement[] so this come to php script as an array, BUT on my local pc if I've added 10 form element i receive 10 elements in $_POST array but on the server this array limited to 6 elements ... do not understand on what this trouble depend ?

for example:

Code:
&lt;form action="blabla" method="post"&gt;
  &lt;input name="FormElement[]" value="1"&gt;
  &lt;input name="FormElement[]" value="2"&gt;
  &lt;input name="FormElement[]" value="3"&gt;
  &lt;input name="FormElement[]" value="4"&gt;
  &lt;input name="FormElement[]" value="5"&gt;
  &lt;input name="FormElement[]" value="6"&gt;
  &lt;input name="FormElement[]" value="7"&gt;
  &lt;input name="FormElement[]" value="8"&gt;
  &lt;input name="FormElement[]" value="9"&gt;
&lt;/form&gt;

in php
Code:
var_export($_POST)

and i see only 6 values instead of 9.
I see from 4 to 9, so first 3 are absent :\ what the php setting or anything other ?

any ideas ?


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Cannot access protected p...
by mywebmanavgat
30 minutes ago
custom validation dinamic
by ozornick
44 minutes ago
QueryBuilder inside
by objecttothis
1 hour ago
DataCaster not working
by kenjis
2 hours ago
Querybuilder select() par...
by objecttothis
5 hours ago
Ci4, CLI Spark Run Standa...
by dhiya as
5 hours ago
How to make nav-link acti...
by luckmoshy
6 hours ago
auth() differs from my lo...
by JohnUK
7 hours ago
Can't read a session
by ElTomTom
Yesterday, 11:06 AM
Shield Common Code to Det...
by Bosborne
Yesterday, 08:36 AM

Forum Statistics
» Members: 86,540
» Latest member: donghomaythuysi
» Forum threads: 77,616
» Forum posts: 376,186

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB