Welcome Guest, Not a member yet? Register   Sign In
  variable name change in a loop
Posted by: El Forum - 10-27-2008, 01:05 PM - Replies (12)

[eluser]earlyriser[/eluser]
Hi.
I would like to change a variable name in a loop, from a view file but I cann't get it work.

My code is

Code:
<?=$row->keyword1?>,<?=$row->keyword2?>,<?=$row->keyword3?>,<?=$row->keyword4?>

&lt;?php for ( $counter = 1; $counter < 5; $counter++)
{    
    echo ${'row->keyword'.$counter};
}?&gt;

The first line is for testing purposes and it writes some keywords from the query results rows. It works fine.

With the FOR loop I want to have the same result, but I got and error:
Severity: Notice
Message: Undefined variable: row->keyword1

What is the correct way to do this? I have tried also
echo ${'$row->keyword'.$counter};
with the same error

Thanks.


  Accessing validation field values in 1.7?
Posted by: El Forum - 10-27-2008, 11:15 AM - Replies (9)

[eluser]degu[/eluser]
Hi,

this is probably a stupid question, but how do I access field values with the new form validation library? In 1.6, you could use:

Code:
$this->validation->title

It looks like there is no equivalent in 1.7? Or am I missing something? I know that I can use set_value, but this is a helper method to repopulate forms. And
Code:
$this->form_validation->_field_data['title']['post_data']
doesn't look correct either.

So, what's the recommended way to access field values in a controller with CI 1.7? Thanks.


  Is CI for me? Just a simple discussion and thoughts sharing.
Posted by: El Forum - 10-27-2008, 10:59 AM - Replies (4)

[eluser]Knitter[/eluser]
Hi,
I just started to use the framework and I intend to replace an existing website with a new one based on CI. Though I know I can research most of this info on the web, I would like to hear from those who use the CI and have developed in it.

I have a simple website with a few complex requirements. First of all, I want the client to control the site, which means I have to develop an easy and non obstructive way of managing everything.

The site has the following features:
a) front page with latest news, only presents the summary.
b) media gallery with image gallery and 'history' gallery, these are documents about a given car, the site is for classic cars and features na history section.
c) page for cars that are available to sell.
d) page for car parts that are sold at the store.
e) provide RSS feeds for all the dynamic items.

I have to create a nice and easy way to manage all the above, so I'll need to provide some sort of WYSIWYG editor, and image editor with the basic batch upload, resize and thumbnail creation, and a gallery manager.

So, to the point, will you consider CI to be able to provide me with all the functionality to create the above scenario? Will I be able to integrate other tools, like the tinyMCE editor or similar, add some AJAX if needed, etc.?


  Can this work? index($myvar)
Posted by: El Forum - 10-27-2008, 10:10 AM - Replies (1)

[eluser]tmac[/eluser]
Hi, I have a question about the index function within a controller.
I know that if I use http://www.mysite.com/page/index/myvar it would work, but how do I get rid of the "index"

Thanks for any info on this Smile


  help with query
Posted by: El Forum - 10-27-2008, 09:29 AM - Replies (5)

[eluser]Fenix[/eluser]
I am trying to pull records from a database and pass the results from a model into a controller. what is the best way to do this? i know i am doing this wrong right now so if somebody could point me in the right direction, that would be great.

my model (there is a field in the database for each of the items in the array):

Code:
function get_assets()
    {
        $this->db->select('*');
        $Q = $this->db->get('assets');
        if($Q->num_rows() > 0)
        {
            foreach ($Q->result_array() as $row)
            {
                $assets = array
                (
                'asset_id'     => $row['asset_id'],
                'file_name'      => $row['file_name'],
                'file_type'      => $row['file_type'],
                'file_path'      => $row['file_path'],
                'full_path'      => $row['full_path'],
                'raw_name'      => $row['raw_name'],
                'orig_name'      => $row['orig_name'],
                'file_ext'      => $row['file_ext'],
                'file_size'      => $row['file_size'],
                'is_image'      => $row['is_image'],
                'image_width'      => $row['image_width'],
                'image_height'      => $row['image_height'],
                'image_type'      => $row['image_type'],
                'image_size_str' => $row['image_size_str']
                );
            }
        }
        else
        {
            // no results
        }
        $Q->free_result();
        return $assets;
    }

my controller:
Code:
function view_assets()
    {
        $this->load->model('assets');
        
        $data['all_assets'] = $this->assets->get_assets();
        
        // Page Data
        $data['page_title'] = $this->config->item('title').': View Assets';
        $data['left_col'] = $this->load->view('admin/anav_view',$data,true);
        $data['center_col'] = $this->load->view('admin/vassets_view',$data,true);
        $this->load->view('template_view',$data);
    }


  "Disallowed Key Characters" error from bad cookies
Posted by: El Forum - 10-27-2008, 08:59 AM - Replies (1)

[eluser]Unknown[/eluser]
The CI site I manage is accessed through a proxy server. One of the other sites accessed through the proxy sets a cookie that causes CI to choke and throw the "Disallowed Key Characters" error. I've looked at the code, and it's pretty strict about what it permits, and I was wondering what problems might result from loosening the restrictions a little bit?


  DB Active record Solution need
Posted by: El Forum - 10-27-2008, 08:35 AM - No Replies

[eluser]bijon[/eluser]
Hi,

i want to get a search user list against a particular id and match the search string either first_name or last_name.
so i do the active record like :

Code:
//*****so many code before//

$this->db->select('*');
$this->db->form('table_name');
$this->db->like('first_name',$params['search']);
$this->db->or_like('last_name',$params['search']);
$this->db->where (array('id' => $id));
I execute the query . The query execute fine. But i do not get the required output.
i fournd that my query generate string is :
Code:
select * from table_name where id=1 and first_name like '%a%' or last_name like '%a%'


Though there is no name match against the id 1 , i still get output where output id shows may be 3 or 4.

So finally i found that if only last_name match then it returns the output . Not check the id. SO I Change the query string where add parenthesis (). I describe below my required query.THIS give me the correct output.
Code:
select * from table_name where id=1 and (first_name like '%a%' or last_name like '%a%')
So my question how can i create that above correct sql using active record.


thanks
saidur
http://saidur.wordpress.com


  SQL Server 2005 Named Instance
Posted by: El Forum - 10-27-2008, 08:28 AM - No Replies

[eluser]Unknown[/eluser]
Is anyone aware of any issues connecting to a named instance of sql server 2005?

Both 1.6* and 1.7 versions of CI can't connect to one.

Any input is appreciated.

Thank you,
Nick


  Little help with CSS
Posted by: El Forum - 10-27-2008, 08:25 AM - Replies (3)

[eluser]iainco[/eluser]
Hey guys, been trying to fix a tiny problem that is bugging me.

Screenshot here: http://img360.imageshack.us/my.php?image=problem.jpg

HTML:

Code:
<div class="news">
            <div class="arrowleft"><img src="images/left.png"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="itemalt"></div>
            <div class="item"></div>
            <div class="arrowright"><img src="images/right.png"></div>
        </div>

CSS:

Code:
.news {width:680px; height:140px}
.arrowleft {float:left; width:20px; height:140px;}
.arrowright {float:left; width:20px; height:140px;}
.item {float:left; width:80px; height:70px; background:#1a7bad}
.itemalt {float:left; width:80px; height:70px; background:#4f9ec4}

I'm using BlueprintCSS but not using the grid, so I've got their reset, typograhpy.

Need the arrowright to sit correctly like the left arrow.

I thought if I gave all divs dimensions in pixels it should all come together.


Also, text will be displayed inside each of the "item" and "itemalt" divs. I'm trying to think of a way to limit how many characters and be able to end the text with "...".

I know I can use overflow:hidden, but that will mean the remaining text is just cut off rather than showing that the text is incomplete.


  escape html-entities
Posted by: El Forum - 10-27-2008, 07:53 AM - Replies (9)

[eluser]sl3dg3hamm3r[/eluser]
Hey there

Form-validator offers to escape html-entities. But is this actually right to escape these stuff before writing to the database? Isn't it rather best practice to store input as it is and escape it after?

If yes, the db-layer doesn't offer any functionality for html-escaping, right? As for me, I didn't find anything like that in the docs.

Sl3dg3


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

Username
  

Password
  





Latest Threads
Cache best practice?
by BhambriRohunu
3 minutes ago
CI 4.5.1 CSRF - The actio...
by BhambriRohunu
12 minutes ago
Bug with sessions CI 4.5....
by InsiteFX
31 minutes ago
Codeigniter Shield Bannin...
by kenjis
5 hours ago
SQL server connection not...
by kenjis
5 hours ago
Best way to create micros...
by kenjis
7 hours ago
How to use Codeigniter wi...
by kenjis
7 hours ago
Getting supportedLocales ...
by kcs
Today, 09:30 AM
Component help
by FlashMaster
Today, 01:41 AM
Show logo in email inbox
by WiParson
Today, 12:48 AM

Forum Statistics
» Members: 85,263
» Latest member: Tripcapturr
» Forum threads: 77,577
» Forum posts: 375,980

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB