Problem with form element

Hello Guys!!!

(Using PHP)

You have helped ma several times, and saved a lot more headach most of the times…

i got one problem today as well, which i am unable to resolve…my project deadline is about to end…you people gotta help me out…plzzzzzzz

There are two SELECTs

  1. I am fetching records(Categories) from database, and preparing the options for SELECT1.

  2. Now i wanna add records from this SELECT1 to SELECT2(should be deleted from SELECT1), and vice verca…

Now i want to take SELECT1 VALUES to Database…

But i am not able to collect the values from this SELECT2, especially when putting that into database.

please help me out…
Here’s the image for your ease.

Do you have any current code?

Yes Sure…

Here’s the code…


if($_POST['work']=="insertcat")
{	

	$business = new business;

	if(!empty($_POST['cat']))
    {
	
		$biz = $_POST['bizval_f'];
		$biz_city = $_POST['city_cat'];
		$cityname = $_POST['cityname'];
		for($i=0; $i<sizeof($_POST['cat']); $i++)
		{
		
		$result = $business->bcc_add($_POST['cat'][$i],$biz_city,$_POST['bizval_f']);		
		//$list1[$i] = $_POST['cat'][$i];
						
		}
		if($result)
			{
		
		$_SESSION["msg"] = "Categories added successfully.";
		
		$url =  "../add_biz.php?id=".$biz."&amp;city=".$cityname;

		header("Location: $url");
		
		die;

			}
		else 
			{
		//$coupon->setsession($set);
		$_SESSION["msg"] = "Error! unable to add subcategories.";
		//header("Location: ../add_coupon.php");
		print("<script language='javascript'>location.href='../add_coupon.php'</script>");
		die;
			}	

	}
}

if($_POST['work']="deleteall")
{	

	$business = new business;

	if(!empty($_POST['cat2']))
    {
	
		$biz = $_POST['bizval_f'];
		$biz_city = $_POST['city_cat'];
		for($i=0; $i<sizeof($_POST['cat2']); $i++)
		{
		
		$result = $business->bcc_delete($_POST['cat2'][$i],$_POST['bizval_f'],$biz_city);		
		//$list1[$i] = $_POST['cat'][$i];
						
		}
		if($result)
			{
		
		$_SESSION["msg"] = "Subcategories Deleted successfully.";
		
		$url =  "../add_biz.php?id=".$biz."&amp;city=".$cityname;

		header("Location: $url");
		
		die;

			}
		else 
			{
		//$coupon->setsession($set);
		$_SESSION["msg"] = "Error! unable to Delete subcategories.";
		//header("Location: ../add_coupon.php");
		print("<script language='javascript'>location.href='../add_biz.php'</script>");
		die;
			}	

	}*/
}
else
{
$_SESSION["msg"] = "Error! work condition doesn't match.";
$url =  "../add_biz.php?id=".$biz."&amp;city=".$cityname;

		header("Location: $url");
		
		die;
}

Here’s how I am calling it.


<input name="insert" type="image" src="img/star-active.png" class="btm" value="Insert" /><input type="hidden" name="work" value="insertcat">

<input name="Delete" type="image" src="img/star-delete.png" class="btm" value="delete" /><input type="hidden" name="work" value="deleteall">

Oh, I see! Without the images, your initial post sounded like a database question (SELECT as in a select query).

So, at what point are you at currently, with the form? And what are you trying to achieve? As much detail and as concise as possible please :slight_smile:

Well, I am still working on it…

My current point:

Now I can Add categories successfully…whatever 1 2…or more…I want at once…

Trying to achieve:
Same function for my second button delete…so that I’d be able to delete 1 2…or more…categories with a single click!!

I think I explained what I want…hope its helpful…

Thanks

I’m trying to figure out where you’re having trouble… you’re having trouble… identifying how to access the elements of the listbox?

name your element box2 or whatever name you want to give it, and then reference the enumerated result array.

$_POST[‘box2’][0] will contain the first selected item… $_POST[‘box2’][1] will contain the second… etc etc. (A Foreach works fine on $_POST[‘box2’])