Welcome Guest, Not a member yet? Register   Sign In
  Validation: Formatting Fields
Posted by: El Forum - 08-25-2007, 09:56 AM - No Replies

[eluser]BrandonDurham[/eluser]
I have a "Daytime Phone" field in my form that I'm validating for length and content regardless of how they enter it. The function I'm using also formats the string to be "(555) 555-5555". I'd like to be able to update that form field with the formatted version once it's been checked. How might I do that?

Thanks!


  RSS Aggregator
Posted by: El Forum - 08-25-2007, 07:11 AM - No Replies

[eluser]Kurai[/eluser]
Hi everyone.
I’m really starting with CI, I like it al lot, but, not being a much of a coder, something is still difficult to figure out for me.

I’m trying to do an RSS aggregator, which displays several sources in several ways (I.E: the last post from a blog, flickr images, the most n recent posts for another blog and so on).

Right now I’m proceeding like this: I’ve made an aggregator view which act as a container, and several other views for various bits of codes (header, footer, and the various RSS boxes) to easily edit them.

Then I’ve installed Simplepie as a class and tried fetching a single RSS source, following literally the tutorial at http://www.nextbigleap.com/blog/developm...deigniter/.

This worked pretty fine, but I’m stuck now. I know I should create a function which takes an url as an argument and then returns the array with the rss feed, but I can’t figure out where to create it (a new library maybe?) and how to call it correctly from the view in which I want to display my feed.

I know thisi is probably quite stupid as a question, but I still have difficulties in understanding the differences between classes, models and libraries.

Can anyone lend me a hand? Thank you!

PS: sorry, I've posted this on the Ignited code section also. It's just an error. If it disturbs, please delete the other one. Thank you.


  RSS aggregator
Posted by: El Forum - 08-25-2007, 04:06 AM - No Replies

[eluser]Kurai[/eluser]
Hi everyone.
I'm really starting with CI, I like it al lot, but, not being a much of a coder, something is still difficult to figure out for me.

I'm trying to do an RSS aggregator, which displays several sources in several ways (I.E: the last post from a blog, flickr images, the most n recent posts for another blog and so on).

Right now I'm proceeding like this: I've made an aggregator view which act as a container, and several other views for various bits of codes (header, footer, and the various RSS boxes) to easily edit them.

Then I've installed Simplepie as a class and tried fetching a single RSS source, following literally the tutorial at http://www.nextbigleap.com/blog/developm...deigniter/.

This worked pretty fine, but I'm stuck now. I know I should create a function which takes an url as an argument and then returns the array with the rss feed, but I can't figure out where to create it (a new library maybe?) and how to call it correctly from the view in which I want to display my feed.

I know thisi is probably quite stupid as a question, but I still have difficulties in understanding the differences between classes, models and libraries.

Can anyone lend me a hand? Thank you!


  redirect won't work
Posted by: El Forum - 08-25-2007, 03:55 AM - No Replies

[eluser]CI_[/eluser]
my redirect() won't fire... please check my codes...

the problem is when I click submit button it goes to another url like sooo

"http://localhost/code_igniter/index.php/blog/index.php/blog/index" as you can see the

URI has been repeated. what did I do wrong here..

Thank you in advance...


Code:
<?Php

    class Blog extends Controller {
    
        function Blog()
        {
            parent::Controller();

            $this->load->helper('url');
            $this->load->helper('form');
        }
    
        function index()
        {

            $data['title'] = 'My Sample Tutorial';
            $data['heading'] = 'This is my Heading';
        
      
            $data['view_data'] = $this->db->get('tblniel');
            
      
            $this->load->view('view_blog', $data);    
        }

        function insert_data()
        {
            $this->db->insert('tblniel',$_POST);
            redirect('blog/index');
        }
}
?>


  SimpleLogin Lib problem
Posted by: El Forum - 08-24-2007, 09:37 PM - No Replies

[eluser]whidbey[/eluser]
my site is ok on windows.

everthing changes when I put my site to freebsd.

and the autoload.php:
$autoload['libraries'] = array('database','session','simplelogin');
wont work now,It says in every controller ,simplelogin is not found.
but I did put it in the lib folder

I use $this->load->library('simplelogin'); wont work either.

both windows and freebsd I use PHP5

help,pls
thx


  Stupid question about query bindings
Posted by: El Forum - 08-24-2007, 05:31 PM - No Replies

[eluser]Martín M.[/eluser]
Hi.

I'm using query bindings to gather data from a database. I have a really simple query:

Code:
$query = $this->db->query("SELECT * FROM table WHERE name LIKE '%?%'", $term);

Of course this doesn't work, since generates this query (note the quotes surrounding the search term):
Code:
SELECT * FROM table WHERE name LIKE '%'yaddayadda'%'

I fixed it this way:
Code:
$query = $this->db->query("SELECT * FROM table WHERE nombre LIKE ?", '%' . $term . '%')

It works, but it feels like it's not a very brilliant thing. Is this the way to go or I'm being really stupid?


  Uploading mpeg video
Posted by: El Forum - 08-24-2007, 04:39 PM - No Replies

[eluser]mjijackson[/eluser]
In the mimes.php file, line 88 should be amended to add video/x-mpeg to the file types.


  Avoid foreach() with Active Record?
Posted by: El Forum - 08-24-2007, 03:56 PM - No Replies

[eluser]stevefink[/eluser]
Hi all,

Is there any possibility for avoiding a foreach() construct when using Active Record type queries? For instance, I'm trying to receive just a single row/value from a table which can simply be assigned to a scaler, so using a foreach construct to get the results seems a bit overkill.

Thanks .... as usual. :-)

- sf


  Flash sendAndLoad and $_POST
Posted by: El Forum - 08-24-2007, 02:16 PM - No Replies

[eluser]bugboy[/eluser]
Hello all.

This is my first post on this forum.

I have recently decided to move over to this frame work as it promotes faster coding and a better way of logic.

Now my question is this. I'm using sendAndLoad on a flash site i'm making at the minute and wanted to use codeigniter for the backend part. (not being built in flash but flash will pull the data out when needed)

When i use sendAndLoad in flash i send the data via $_POST. The function in the controller at the min looks like this.

Code:
function forflash(){
    
    if(isset($_POST['id'])){
        $id = $_POST['id'];
    }else{
        $id = '0';
    }
    
    $xml['xml'] = $this->country->getCountriesReturn($id);
    $data['content'] = $this->load->view('country_xml',$xml,true);    
    $this->load->view('country_xml', $data);

    }

Now the code above works like a dream but i was wondering if this was the best approach. This isn't validated but hopefully you'll understand what i mean.

I'm trying to use the MVC way.


other parts of my code looks like this

model:
Code:
function getCountriesReturn($id)
    {    
        
        $this->db->select('id, name');
        $this->db->where('id', $id);
        $this->db->from($this->_table);
        $query = $this->db->get();
        if ($query->num_rows() > 0)
        {
            return $query->result();
        }
             return null;
    
    
    }


view:
Code:
<?php
$output = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
$output .= '<cms_item>'."\n";
if ($xml != null){
        foreach ($xml as $array){
        $output .= ' <item>'."\n";
        while(list($key, $value) = each($array)){
            if($value !='0'){
                $output .= '  <'.$key.'>'.$value.'</'.$key.'>'."\n";
            }
        }
        $output .= ' </item>'."\n";
    }
    $output .= '</cms_item>'."\n";
}else{
$output .= ' <cms_item><item><report>No data to show</report></item></cms_item>'."\n";
}
echo $output;
?&gt;

Now my gut instinct on this is if it works why worry but you know perfection an all that.

Any help great thanks in advance.


  Pagination help (yep again)
Posted by: El Forum - 08-24-2007, 02:15 PM - No Replies

[eluser]kevinprince[/eluser]
This seems to be a runnning theme here.

Basically trying to do a simple pagination of data results.

Ive got it counting number rows, and doing the actual pagniation links, i just cant seem to get actual variables to pass. eg if its /person i just want it to start at 0 if its /25 it starts a 25.

The current solutions just 404's when i click the link and also when i try to echo $start it just comes up blank.

Thanks code below.

Code:
function index()
    {
        ///Load the CI LIbraries we need for this functuon
        $this->load->library('table');
        $this->load->library('pagination');
        
        ///Config for Pagination including getting the total number rows in DB
        $config['base_url'] = 'http://www.vk_server.vk/index.php/person/';        
        $config['total_rows'] = $this->db->count_all('vk_people');;
        $config['per_page'] = '25';
        $this->pagination->initialize($config);
        
        ///Setup the starting point for the query
        
        if (!$this->uri->segment(4)) {$start = 0;} else {$start = $this->uri->segment(4);}
        
        $query = $this->db->query("SELECT sname, fname, address, phone, mobile FROM `vk_people` ORDER BY `sname` ASC LIMIT $start, $config[per_page]");
        
        $this->table->set_heading('Surname', 'First Name', 'Address', 'Phone', 'Mobile');


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

Username
  

Password
  





Latest Threads
Changing Session cookie -...
by codeus
5 hours ago
hot-reload side effects s...
by PaulC
Today, 02:44 AM
using app/Config/App.php ...
by sam547
Yesterday, 03:04 PM
Setting baseURL in Regist...
by grimpirate
05-15-2025, 02:20 PM
CRUD Code Generator
by DeanE10
05-15-2025, 05:31 AM
CodeIgniter.com - Report ...
by Harry Lyre
05-14-2025, 04:26 AM
Missing closing bracket w...
by abf
05-13-2025, 07:27 PM
Update from 4.6.0 to 4.6....
by FlavioSuar
05-13-2025, 04:17 AM
Sessions old files are de...
by InsiteFX
05-12-2025, 10:30 PM
Ajax post failing with Ty...
by PaulC
05-12-2025, 12:23 AM

Forum Statistics
» Members: 146,588
» Latest member: 889aco
» Forum threads: 78,392
» Forum posts: 379,465

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB