Hi all,
I am having the following problem. I have made a page where I can add new items, which can be connected with multiple categories. Please see below the part of the page / form, which will lead to new_add.php:
[code]new.php
Website | |
<?php
$query=mysqli_query($conn, "select * from category")or die(mysqli_error($conn));
while($row=mysqli_fetch_array($query)){
$category_id=$row['id'];
?>
<?php echo $row['type'] ?> | <?php echo $row['name'] ?> |
[code]new_add.php
<?php $url = check($_POST['url']); $email = check($_POST['email']); $id=$_POST['selector']; $N = count($id); for($i=0; $i < $N; $i++) { $result = mysqli_query($conn, "SELECT * FROM category where id='$id[$i]'"); while($row = mysqli_fetch_array($result)) { } } $sql = "INSERT INTO test(id, url, email, category_id) VALUES (NULL, '{$url}', '{$email}', '{$category_id}');"; $retval = mysqli_query($conn, $sql); if(! $retval ) { die('Could not enter data: ' . mysqli_error($conn)); } ?>[/code]I want to connect the with checkboxes selected categories to the other table (test), however I cannot get it to work. I must be missing something. Hope somebody can point me in the right direction and help me out. It would be much appreciated.
Many thanks in advance.