I am trying to learn php and I have read and looked but cannot find a solution to this.
What I am trying to do is when I add a new product, I may need to put it into a new Category which I specify with text.
I have a dropdown of existing categories, and below that I have a field that is "New Category". (where I can input a new category if needed)
How would I would I add the text field into the table 'category' as a new one? I tried but I got the error "Column 'category' specified twice"
Here is the code I have.
HTML
<div class="col-md-8">
<select name="category">
<option value="">Choose Category</option>
<option value="Category1">Category1</option>
<option value="Category2">Category2</option>
</select>
</div> <!-- /.col -->
<div class="col-md-8">
<input type="text" name="addcat" value="" class="form-control" />
</div> <!-- /.col -->
PHP
$category = $_POST['category'];
$addcat = $_POST['category'];
$query="INSERT INTO new_equip(`id`,`category`,`category`,)
VALUES('$id','$category','$addcat')";
mysql_query($query) or die(mysql_error());
echo mysql_error();
Would I need to add something like this?
@mysql_query("ALTER TABLE `categories` ADD `$addcat` VARCHAR( 100 )") or die(mysql_error());