Welcome Guest, Not a member yet? Register   Sign In
  Multidimensional session data
Posted by: El Forum - 10-19-2007, 05:05 PM - No Replies

[eluser]spheroid[/eluser]
How is it possible to do the following refactored for CI? Having difficulty compared to the documentation:

1. Increase the value by 1

Code:
$_SESSION['cart_product_qty'][$i]++;

2. Compare a multidimensional session array key
Code:
if ($_SESSION['cart_product_id'][$i] == $product_id) ...

3. Set a session variable using an array key
Code:
$_SESSION['cart_product_qty'][] = 1;

4. Display a multidimensional session variable
Code:
echo $_SESSION['cart_product_qty'][$i];

I'm not sure if it's possible to use these type of multidimensional session variables??


  How to "install" xajax in CodeIgniter??
Posted by: El Forum - 10-19-2007, 04:46 PM - No Replies

[eluser]Unknown[/eluser]
hello!!
i have been trying out the xajax library in CodeIgniter and always a got this error

Quote:Fatal error: Call to undefined method xajax::processRequests()
it don't recognize the processRequests() function... i don't know what to dou to fix it...
anyone could help me to use or "instal" tha xajax library in CodeIgniter... i got the full package of xajax 0.5 beta 4... How to "install" xajax in CodeIgniter!!


  CI & IIS: Selects the controllers right, but doesn't execute the code?
Posted by: El Forum - 10-19-2007, 03:48 PM - No Replies

[eluser]jimmy0x52[/eluser]
Hi,

I've got CI running on IIS. I've got it running with ISAPI_rewrite and can successfully access my controllers using

http://www.website.com/index.php/controllername

The problem is the controller contents come up and are not rendered/executed by PHP/CI. I get the actual code spit out at me.

Does anyone have any ideas why this is? I've got PHP installed as an ISAPI module with the correct web service extensions - and I know that rewrite is working because I can switch between controllers - it just will not render the output once it's grabbed from the controller.

Anyone have this issue as well? I can't seem to find an answer.


  posting the latest of something to the top of the row
Posted by: El Forum - 10-19-2007, 02:24 PM - No Replies

[eluser]mdriscol[/eluser]
Hi, I'm new to this.

I have a page displaying data from a table with foreach($announcements->result() as $row):

When its displayed each new row is displayed below the oldest but I want to do that in reverse order. The newer posts need to be on the top instead of the bottom of the table.

How can I accomplish this?

Should I be using a function that reorders the table in the database or a function that displays foreach in reverse on the view?


  Routes: how to get mycontroller/id function same as mycontroller/action/id
Posted by: El Forum - 10-19-2007, 10:26 AM - No Replies

[eluser]dreamynsx[/eluser]
Hello, I've read routes documentation already, but it really does not have a lot of examples for what I'm trying to do. Please help.

Code:
// my sample class with index action
class MyController extends Controller
{
    function index($id="")
    {
        // do fun things here
    }

    function add() {
       // do more fun things here
    }

}


How do I get it so that both requests like this work:

www.site.com/mycontroller/index/3<-- this works by default, sets $id value to 3

www.site.com/mycontroller/3 <-- this fails with 404, since '3' is not valid action

www.site.com/mycontroller/add <-- this works as expected

www.site.com/mycontroller <-- this will work and load index action by default


This is simply because I don't want to use url like www.site.com/cars/index/3 as I think having index at the end of every section looks funny. So www.site.com/cars/3 is what I want to work.


Thanks!


  upgrading from 1.3.3 to 1.5.4
Posted by: El Forum - 10-19-2007, 10:20 AM - No Replies

[eluser]mdg5w[/eluser]
I just upgraded this morning and it seems like for the most part my site is still working.

However,

http://mysite.com/controllerName/

doesn't work. but.

http://mysite.com/index.php/controllerName/

does.

This is only the case for 1 controller.

Any thoughts?


  How to include pre-written libraries?
Posted by: El Forum - 10-19-2007, 09:12 AM - No Replies

[eluser]jahboite[/eluser]
Hello!

Bit of background:
I'm developing an application for facebook. Before attempting this, I'd never written any php and I'm not completely au fait with javascript. I started development on my app from scratch using notepad (well Textpad actually, but manually is what I mean) and then I found out that other people were using php frameworks like drupal and CodeIgnitor. I couldn't believe I'd missed such a thing.

Yesterday I decided to get hold of CI and started learning about it, playing with it and started to recreate my application using it. It looks like a great bit of kit and I was hooked once I'd watched the tutorial vids.

Facebook provides some php classes and I needed to work out how to use these with CI. At first, I just php included them, but was getting some undefined index notices. Did a bit of research and decided to load the facebook classes as plugins. This seems to have worked nicely and CI stopped complaining about the index.

Then I was reading about CI libraries and I thought I'd have a go at loading the facebook classes as libraries instead. I had to capitalise the filenames, and I also separated an existing php file into two separate php files, one for each of two classes, naming the files the same as the contained class...

Trouble was CI started warning me about missing arguments for the functions as they were instantiated. I played and fiddled, but realised I was fumbling around in the dark so I went back to loading as plugins.

My question is, given an external library, what's the proper way to use them within CI such that one doesn't have to rewrite them or make major mods?


  DB Query Returns
Posted by: El Forum - 10-19-2007, 08:11 AM - No Replies

[eluser]Daburn[/eluser]
Hi Guys

I'm trying to become acquainted with CodeIgniter but now facing a problem with the returns of my DB query. I want to give all the values with no content the value "keine Angaben". Because else, the table cells with no content won't be draw.

My Model:

Code:
function list_stocks() {
            $query = $this->db->query('SELECT * FROM stocks');
            foreach ($query->result() as $value) {
                if (strlen($value) == 0) $value = "keine Angaben";
            }
            return $query;
        }

My Controller:
Code:
$this->load->model('Home_model','', TRUE);
$data['query'] = $this->Home_model->list_stocks();
                    
$this->load->view('loader', $data);

Obviously, $query returns an object, but I'm not sure how to realise it else without addressing each result separately with:
Code:
if ($row->name == "") $row->name = "&nbsp;"
if ($row->price == "") $row->price = "&nbsp;"

Thanks a lot,
Daburn


  [solved] validation class - callback functions
Posted by: El Forum - 10-19-2007, 06:57 AM - No Replies

[eluser]obiron2[/eluser]
Hi guys,

I am trying to extend my knowlege of some of the more advanced functions in CI.

I have a form which requires a start and end date, populated as 3 fields per date Sday,Smth,Syr and Eday,Emth,Eyr

I would like to use the validation class to do the following:

Validate that each field is populated and is numeric and no more than 2 digits long - easy - 'required|trim|numeric|max_length[2]'.

Validate that when Sday,Smth,Syr are combined together they form a valid date

Validate that the start date is before the end date

Validate that the start date is after a date pulled from the database

I don't really understand what is happening with $rules[] and $fields[] and what the validation class then does with them

Can anyone point me in the right direction on how to combine fields together in validation rules.



Thanks

obiron


  Edit form and validation... big problem
Posted by: El Forum - 10-19-2007, 06:20 AM - No Replies

[eluser]ariok[/eluser]
Hi!
I have a question (that i hope could find an answer... -.-) about the validation class..

it's really hard for me understand how to manage a form where i have dinamic fields..

In my edit Form i have these steps:
1) load page taking data from db and set input value with this data.
2) send data
3) if there are some errors, load again edit form with $this->validation->fieldname value
rather than Db value as values for input field.

here some parts of my view code:

This is for input text field :

Code:
&lt;input id="username" name="username" type="text" value="&lt;? echo ($this-&gt;validation->username!=false or $this->validation->username_error!="") ? $this->validation->username : $userdata->username ;?&gt;"/>

So for this situation is ok.. but if have dinamic fields in my form...
(like list of permissions with a checkbox to assign permissions to a users)... what i have to do?!?

I try to generate fields dinamicaly with this code in my controller
Code:
foreach ($queryAllGrp->result_array() as $ngrp) {    
            $fields["id".$ngrp['id']] = "id{$ngrp['id']}";
        }
        $this->validation->set_fields($fields);

and set view in this mode..($allGrp contain $queryAllGrp->result_array());

Code:
<table border='1'>
    &lt;? foreach($allGrp as $grp): ?&gt;
         <tr>
            <td>&lt;input type="checkbox" name="id&lt;?=$grp["id"]?&gt;" value="&lt;?=$grp["id"]?&gt;" &lt;? $var ="id".$grp['id']; echo ($this-&gt;validation->$var!=false) ? $this->validation->set_checkbox('id'.$grp["id"],$grp["id"]) : isMyGrp($grp["id"],$myGrp);?&gt; /> </td>
         </tr>
    &lt;? endforeach; ?&gt;
    </table>

But it seems that ($this->validation->$var!=false) is not the right way..
.. uhm... too confused... !!!!

is there a way to do this??
is not so strange to have dinamic form!! Big Grin

thank you all .. and sorry for my terrible English


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

Username
  

Password
  





Latest Threads
Changing Session cookie -...
by codeus
1 hour ago
hot-reload side effects s...
by InsiteFX
4 hours ago
using app/Config/App.php ...
by sam547
11 hours ago
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,483
» Latest member: mocmm
» Forum threads: 78,392
» Forum posts: 379,462

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB