View Single Post
Old 06-14-2011, 09:56 PM  
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,409
This is the form field and it will allow for more than one selection:

Code:
          <select name="blogs[]"  size="55" multiple="multiple" style="font-size:10px;"><? displayBlogs(); ?></select>

This is the function that created the list in the form field:

Code:
function displayBlogs() {
	global $getquery,$optionrows,$blogs;
	//$count = mysql_num_rows($getquery);
	while ($optionrows = mysql_fetch_assoc($getquery))
	{
	$select = '';
	for ($x=0;$x<count($blogs);$x++)
		{ 
		if ($blogs[$x] == $optionrows["id"]) { $select = ' selected '; }
		}
	echo "<option value=\"".$optionrows["id"]."\"$select>".$optionrows["name"]."</option>";
	
	}

}

This captures the field:

Code:
$blogs = $_POST['blogs'];

This forms the statement:

Code:
for ($x = 0;$x<count($blogs);$x++) 
		{ 
		if ($x<count($blogs)-1) { $ids .= "id = $blogs[$x] or "; }
		else { $ids .= "id = $blogs[$x]"; }
		}

This selects them from the DB:

Code:
$grabblog = mysql_query("select * from blogs where ($ids) order by name;",$wp) or die (mysql_error());

Now you can do with them what you want:

Code:
while ($rowsgrab = mysql_fetch_assoc($grabblog))
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote