Jump to content

Array Problem


project3

Recommended Posts

ok, I have a multiple select box which I made an array Im trying to insert the values into the db.

instead of inserting the values its inserting

 

Array[1],Array[2]

 

$this_new is what im inserting into the db at the bottom of the code below.

 

$ix = 1;

$array_count = count($this->MTime);

$this_old = "";

 

while($ix <= $array_count){

 

if ($ix == 1){

$this_old .= "$this->MTime[$ix]";

}else{

$this_old .= ",$this->MTime[$ix]";

}

 

$ix = $ix + 1;

 

}

 

$this_new = $this_old;

Link to comment
Share on other sites

what does this give

 

echo '<pre>';
print_r ($this->MTime);
echo '</pre>';

 

 

I changed  the code and took the array out of the " " and it worked.

 

$ix = 0;

$array_count = count($this->MTime);

$array_count = $array_count - 1;

 

$this_old = "";

 

while($ix <= $array_count){

 

if ($ix == 0){

$this_old .= $this->MTime[$ix];

}else{

$this_old .= ",";

$this_old .= $this->MTime[$ix];

}

 

$ix = $ix + 1;

 

}

 

$this_new = $this_old;

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.