Welcome Guest, Not a member yet? Register   Sign In
Problem with echoing contents from database to multiselect form.
#1

[eluser]BufferOverflow[/eluser]
I am building a site that needs;

1-) Variety of forms, some are radio, some are checbox, some are select, some are multiselect.
2-) When we submit the forms go to at least 3 tables in database.
3-) If user filled his/her form before the contents of the form must be filled with data from database.
4-) At this time if he/she clicks submit the form and changes something and an error occurs:
-Unchanged fields must echo the values from database(if the column is not empty)
-Changed fields must echo the values from POST array.

5-)When we first visit the form page; if the form was all empty:
-PHP should not complain. An example:

Code:
echo $database->value1;
Code:
PHP error value1 doesn't exist
Code:
foreach($database as $data
Code:
Wrong data type supplied for foreach

Cause the row, value1 is empty and $database object doesn't exist.

I nearly solved all of the problems by
1-)Creating my own if/else statements and foreachs inside the view. For database and POST two of them.
2-)For the forms that are empty(not the entire form page is empty, some of them are empty):
Code:
foreach ($records as &$record) {
    if(!@$record) {
        $record = '';
    }
}

I solved everything. Except one. PHP go and complain if all the form is empty.

So in the model file i went and created this control:
Code:
If num_rows() empty:
SELECT FIELDS FROM TABLE EXAMPLE
Create an empty object with all fields in table as empty properties.

But as i said i use more than one table and i can't join the Fields from other tables. Do you have a solution?
#2

[eluser]BufferOverflow[/eluser]
No solution? Sad
#3

[eluser]Wondering Coder[/eluser]
use CI active record for joining tables. its in the user guide.
#4

[eluser]BufferOverflow[/eluser]
I am already doing it. It is not about joining the tables. Did you read the post?




Theme © iAndrew 2016 - Forum software by © MyBB