I have the following code, which tries to see if someone selected a drop down menu item that is already part of the database. If it is, then the error message should show up.
$size_of_user_array = count($user_selects);
$size_of_db_array = count($already_in_db);
for($y=0;$y<$size_of_user_array;$y++)
{
$input = $user_selects[$y];
for($r=0;$r<$size_of_db_array;$r++)
{
//echo "Already in $r = " .$already_in_db[$r];
//echo " ";
//echo "user_selects[ $y ] = " . $user_selects[$y];
$db_output = $already_in_db[$r];
echo " $db_output = $input ";
if($input == $db_output)
{
echo "Table ". $already_in_db[$r] . " is already a part of database " . $_SESSION['category'] . "Please make your selections again";
exit();
}
}
if($input == "none")
{
// do something else
}
else{
$database_name = $_SESSION['category'] . "." . $input;
//$sql=create_table($database_name);
//echo "database name = " . $database_name; // for debugging
//echo "Session abbr = " . $_SESSION['Abbr']; // ok ok, so perhaps I'm a little overkill with the debugging
//echo "Input = " . $input; // but isn't it nice to just uncomment and see the stuff?
//mysql_query($sql) or die("error making table! Please contact system admin for more help." . mysql_error());
//echo "Table Created!<br>";
//update_control($_SESSION['category'],$_SESSION['Abbr'],$input);
}
}
}
?>
The output for the code is as follows
array(5) { [0]=> string(8) "boxsets " [1]=> string(4) "none" [2]=> string(4) "none" [3]=> string(4) "none" [4]=> string(4) "none" } array(4) { [0]=> string(11) "accessories" [1]=> string(5) "track" [2]=> string(4) "sets" [3]=> string(7) "boxsets" }
accessories = boxsets
track = boxsets
sets = boxsets
boxsets = boxsets <- should trigger
accessories = none
track = none
sets = none
boxsets = none
accessories = none
track = none
sets = none
boxsets = none
accessories = none
track = none
sets = none
boxsets = none
accessories = none t
rack = none
sets = none
boxsets = none
But it doesn't.
Can someone point out my mistake?
Thanks!
Kris