Welcome Guest, Not a member yet? Register   Sign In
Working with Multi-Select & Dropdowns and SQL
#11

[eluser]Philipp Gérard[/eluser]
Your PHP code makes no sense.

$this->input->post("fieldname") equals $_POST["fieldname"] (accessing it via $this->input->post however is more safe generally speaking). Basically, you only set $_POST["x"][some_row] = $_POST["x"] ($data = one row of your array). Imagine an array like a 2 column table, using foreach means that you go through the table row by row accessing the value of the 2nd column using $data. If you also want to access the value of the first column, use foreach($array as $column_1 => $column_2){ ... }. I hope this clears up your confusion.

If you still have trouble, please post me the "virgin" version of your array, the way it hits your controller before you did any confusing stuff to it and tell me how you want your results ordered. I'll then show you the implementation.
#12

[eluser]Bionicjoe[/eluser]
True enough.
I eliminated all that foreach stuff & I still have the exact same problem. So all that previous code was junk.

Code:
function updateoutage()
  //Submit the updated outage data to the DB.
  {
    $this->load->model('outage_model','',TRUE);
    
    //$this->outage_model->updateoutage($_POST['outageid'], $_POST);
    print_r($_POST);
#13

[eluser]Philipp Gérard[/eluser]
Please post me the output of print_r($_POST);

...
#14

[eluser]Bionicjoe[/eluser]
using this method "$_POST['servicename'] = $data['servicename'];"
Code:
Array (
[outageid] => 2
[ticketnumber] => INC000000000002
[servicename] => H
[location] => L
[impact] => 5000
[starttime] =>
[endtime] =>
[summary] => Sample Ticket 2
[details] => Some details...
)

Using this method "$data = $this->input->post('serviccename');"
Code:
Array (
[outageid] => 2
[ticketnumber] => INC000000000002
[servicename] => Array ( [0] => Video [1] => HSI )
[location] => Array ( [0] => Columbus [1] => Lexington )
[impact] => 5000
[starttime] =>
[endtime] =>
[summary] => Sample Ticket 2
[details] => Some details...
)
#15

[eluser]Philipp Gérard[/eluser]
just the plain $_POST please...It's hard to reverse engineer your faulty arrays. You have a "vanilla" version that wasn't modified by your code, post that please.
#16

[eluser]Bionicjoe[/eluser]
Umm...That's what I'm doing.
print_r($_POST);
#17

[eluser]Philipp Gérard[/eluser]
[quote author="Bionicjoe" date="1277994527"]using this method "$_POST['servicename'] = $data['servicename'];"
Code:
Array (
[outageid] => 2
[ticketnumber] => INC000000000002
[servicename] => H
[location] => L
[impact] => 5000
[starttime] =>
[endtime] =>
[summary] => Sample Ticket 2
[details] => Some details...
)

Using this method "$data = $this->input->post('serviccename');"
Code:
Array (
[outageid] => 2
[ticketnumber] => INC000000000002
[servicename] => Array ( [0] => Video [1] => HSI )
[location] => Array ( [0] => Columbus [1] => Lexington )
[impact] => 5000
[starttime] =>
[endtime] =>
[summary] => Sample Ticket 2
[details] => Some details...
)
[/quote]

Post $_POST using none of the above faulty methods.

function your_function()
{
print_r($_POST);
die;
}
#18

[eluser]Bionicjoe[/eluser]
Code:
Array (
[outageid] => 2
[ticketnumber] => INC000000000002
[servicename] => Array ( [0] => Video [1] => HSI )
[location] => Array ( [0] => Columbus [1] => Lexington )
[impact] => 5000
starttime] =>
[endtime] =>
[summary] => Sample Ticket 2
[details] => Some details...
)
Code:
function updateoutage()
  {
    $this->load->model('outage_model','',TRUE);

    print_r($_POST);
  }


Model function
Code:
function updateoutage($id, $data)
    // Update one outage record
    {
      $this->db->where('outageid', $id);
      $this->db->update('outage', $data);
    }
#19

[eluser]Philipp Gérard[/eluser]
Alright, that looks better. Your arrays are "servicename" and "location" and contain those elements selected by the user (Video, HSI and Columbus, Lexington). What exactly do you now want to save to the database?
#20

[eluser]Bionicjoe[/eluser]
This is the update statement sent to the DB.

Code:
UPDATE `outage` SET
`outageid` = '2',
`ticketnumber` = 'INC000000000002',
`servicename` = Array,      <-- Problem
`location` = Array,       <-- Problem
`impact` = '5000',
`starttime` = '',
`endtime` = '',
`summary` = 'Sample Ticket 2',
`details` = 'Some details ...'
WHERE `outageid` = '2'

That WHERE at the end is not needed.




Theme © iAndrew 2016 - Forum software by © MyBB