I am saving data to a mysql database and these are going to be different options, rather then having them in their own column i am trying to to keep them in the same.
So like surface in mysql would look like : grass,pavement,tarmac - i can get the data to show, but i cannot for some reason get it to save, after either adding a new option or deleting an option.
EDIT - This is now working, i reposted it on here incase others needs help! Thanks
Add:
$surface = mysql_real_escape_string($_POST['surface']);
$array = explode(',',$setQuery['Surface']);
$new_array = implode(',',$array).','.$surface;
$saveSettings = mysql_query("UPDATE `settings` SET Surface = '$new_array' WHERE id = '1'");
Delete:
$surface = mysql_real_escape_string($_GET['s']);
$array = explode(',',$setQuery['Surface']);
unset($array[$surface]);
$new_array = implode(',',$array);
$saveSettings = mysql_query("UPDATE `settings` SET Surface = '$new_array' WHERE id = '1'");
Thanks for any help regards
forloop nonsense to join array elements into a string and useimplode()$new_array = implode(",", $array);mysql_query(...) or die(mysql_error()), you'd be told why your queries are failing.mysql_query()? Checkmysql_error(). Also, your add takes from$_POSTwhile your delete takes from$_GET. In neither case have you calledmysql_real_escape_string()to escape the input value before querying...