Jump to content

[SOLVED] mutiple select- into query


ag3nt42

Recommended Posts

I have a multiple selection form setup.. I'm trying to be able to post it..

 

then plug those values into a delete query.. but i'm having the damnest time..

 

any help is appreciated..

 

here is the select form:

 

<?php
					<form action='../Ca_info/Cct_info.php' method='post'>
						<select multiple name='TypeDelete[]' size='10'>
		");

		////////////////////////
		//* SNATCH AVAILABLE *//
		////////////////////////

		//* STOP THE BITCHING *//
		$Z=array('','','','','');

		$database=$tblpre."ClientType";
		$AvailableSQL="SELECT Type FROM [".$database."] ORDER BY Type";
		$result=mssql_query($AvailableSQL)or die(mssql_error());
		$count=mssql_num_rows(mssql_query($AvailableSQL));
		$y=0;
		while($row=mssql_fetch_row($result))
		{
		$Z=$row[0];

		echo("
							<option value='".$Z."'>".$Z."</option>						
		");
		$y++;
		}

		echo("
						</select>
				</td>
			</tr>
			<tr>
				<td>
					<input type='submit' value='Delete' name='action' />
				</td>
			</tr>
		");
?>

 

 

and here is the code i have so far on the other side:

 

<?php

////////////////////////////
//************************//
//* Setup SQL Variables  *//
//************************//
////////////////////////////
//The Table+Prefix
$datatable=$tblpre."ClientType";


//COLLECT DELETE INPUT
if(isset($_POST['TypeDelete']))
{
$T=0;

foreach ($_POST['TypeDelete'] as $Type) 
{
	$T++;
}


for($x=0;$x<=$T;$x++)
{
	$Dtype[$x]=$_POST['TypeDelete'][$x];
	$TypeDelete[$x]="DELETE FROM [".$datatable."] WHERE Type='".$DType[$x]."'";
}
}



$TypeInsert="INSERT INTO [".$datatable."] VALUES ('".$Ctype."');";


////////////////////////////
//************************//
//* Start SQL Injections *//
//************************//
////////////////////////////
$Success=0;
$Fail=0;
// IF ADDING
if($Delete=='No')
{
if(mssql_query($TypeInsert))
{
	echo("<font color='green'>".$Ctype."Type Added Successfully!</font><br />");
	$Success++;
}

else
{
	echo("<font color='red'>".$Ctype."FAILED</font>".mssql_error());
	$Fail++;
}
}
//IF DELETING
elseif($Delete=='Yes')
{
for($x=1;$x<=$T;$x++)
{
	if($Type[$x]=="")
	{
		echo('');
	}
	else
	{
		if(mssql_query($TypeDelete[$x]))
		{
			echo("<font color='green'>Type Deleted Successfully!</font><br />");
			$Success++;
		}
		else
		{
			echo("<font color='red'>FAILED</font>".mssql_error());
			$Fail++;
		}
	}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/115862-solved-mutiple-select-into-query/
Share on other sites

every time tho i get a

 

Notice: Undefined variable: DType in \Cct_info.php on line 66

 

Notice: Undefined variable: DType in \Cct_info.php on line 66

 

Notice: Undefined offset: 2 in \Cct_info.php on line 65

 

Notice: Undefined variable: DType in \Cct_info.php on line 66

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.