Jump to content

splitting an array


tigomark

Recommended Posts

Ok I am trying to first get a list of stuff from an array created from a database.

 

I am able to do that in funcion LeftSelect but what I would like to do is separate out values that are grabbed from another call

and stored in $this->right_asset (vars 1,2,3,4)

the values then would populate the RightSelect

 

 

function LeftSelect(){
  $assets = loadAllStuff($getConnection);					
  $html = "<select name=\"target\" multiple=\"multiple\">\n";
    
  if(is_array($assets)){
    while(list ($key, $val) = each($assets)){
    	
    	if (in_array($val->id, $this->asset_select_right)) {
    		array_push($this->right_asset,($val->id, $val->stuff));
    	}else{
  $html .= sprintf("<option value=\"%d\">%s</option>\n",
      $val->id,
      htmlspecialchars($val->stuff));
      }
    }
  }
  $html .= "</select>\n";
  return($html);
}//assetSelect

function RightSelect(){
$html .=sprintf("
<select name=\"selected\" size=\"10\">");

if(is_array($this->right_stuff)){
while(list($key, $val) = each($this->right_stuff)){
 $html .= sprintf("<option value=\"%d\">%s</option>\n",
      $val->id,
      htmlspecialchars($val->stuff));	
}
}	
  	$html .=sprintf("</select>");	
  	
 return($html);
}

 

 

 

I am trying

 


if (in_array($val->id, $this->asset_select_right)) {
    		array_push($this->right_asset,($val->id, $val->stuff));

 

which is currently not working in the left. If I take out the if I do get the all of the values so that is working.

 

and the RightSelect is all fubar so I am kinda stuck.

 

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.