project3 Posted February 27, 2008 Share Posted February 27, 2008 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; Quote Link to comment Share on other sites More sharing options...
Barand Posted February 27, 2008 Share Posted February 27, 2008 what does this give echo '<pre>'; print_r ($this->MTime); echo '</pre>'; Quote Link to comment Share on other sites More sharing options...
project3 Posted February 27, 2008 Author Share Posted February 27, 2008 what does this give echo '<pre>'; print_r ($this->MTime); echo '</pre>'; the sql is in an include file and I cant get text output to show up. If I just change the code to $this_new = $this->MTime[1]; and just select one it gets it ok. Quote Link to comment Share on other sites More sharing options...
project3 Posted February 27, 2008 Author Share Posted February 27, 2008 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; Quote Link to comment Share on other sites More sharing options...
Barand Posted February 27, 2008 Share Posted February 27, 2008 In that case, instead of your while loop, try $this_new = join (',', $this->MTime); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.