避免PHP中的重复ID

EDIT: Question edited to be exact after Marcus reply

I am trying to practice library management and my page is for order where a book can be ordered as many time but same book should not be selected in two different selects on one page. On order page, I have multiple select dropdowns for book values coming from same database:

<select name="user">
<option value="1">Tony</option>
<option value="2">Gary</option>
<option value="3">Martin</option>
<option value="4">Austin</option>
<option value="5">Mark</option>
</select>

<select name="book[]">
<option value="1">Math</option>
<option value="2">Geography</option>
<option value="3">Science</option>
<option value="4">Spanish</option>
<option value="5">English</option>
</select>

<select name="book[]">
<option value="1">Math</option>
<option value="2">Geography</option>
<option value="3">Science</option>
<option value="4">Spanish</option>
<option value="5">English</option>
</select>

<select name="book[]">
<option value="1">Math</option>
<option value="2">Geography</option>
<option value="3">Science</option>
<option value="4">Spanish</option>
<option value="5">English</option>
</select>

And adding them in database table which has ID as auto increment for record and bookID to store book id. I am doing it with:

$userID = $_POST['user'];
    foreach($_POST['book'] as $key=>$item_eid){
    $bookID = intval($_POST['book'][$key]);
    mysql_query ("Insert INTO user_books (bookID, userID) values ('$bookID', '$userID' )") or die(mysql_error());
    }

I dont want to have two record of same book ID. In short, I want to avoid duplicate entries on bookID. I have tried "INSERT IGNORE INTO" but it did not work. Also, I want to show an error if duplicate entries are selected instead of just ignoring. Any thoughts on it?

Edit: Table structure:

CREATE TABLE IF NOT EXISTS user_books
(
    ID int(11) NOT NULL AUTO_INCREMENT, 
    bookID int(11) NOT NULL, 
    userID int(11) NOT NULL, 
    added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP 
) 
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ; 

The column needs to be UNIQUE. Right now there is no constraint on the column which is allowing it to have duplicate values. Change the column to UNIQUE:

ALTER TABLE user_books ADD UNIQUE (bookID);

This query will fail, however, if you already have duplicate values in the bookID column. If you don't care about the (automatic) removal of duplicate entries, use the following query instead:

ALTER IGNORE TABLE user_books ADD UNIQUE (bookID);

This will keep the first found entry of any duplicates, and delete the rest, ie. Imagine having 5 entries with bookID 100. The aforementioned query will keep the first entry with bookID 100, and delete the remaining 4 automatically.

Then you can use INSERT IGNORE INTO thereafter.