I have a question: I have 2 tables in my database:
articles:
id  useid  title
users
id  name  surname
My view:
 Author<select name="author" id="author">
                            <?php foreach ($users as $u): ?>
                                <option value="<?php $u['id'] ?>" <?php if($u['id']==$a['userid']): ?> selected="selected" <?php endif ?> style="width:300px"><?php echo $u['name'] ?> <?php echo $u['surname'] ?></option>
                            <?php endforeach; ?>
        </select>
        <p><b>Content:</b></p>
        <textarea name="content" id="content" style="width:605px; height: 300px;" rows="200"><?php echo $a['content']; ?></textarea>
My Controller:
$this->db->query("UPDATE articles SET title='$title',userid='$author' WHERE id=$aid" );
When I do this I got the error 1452: Cannot add or update a child row: a foreign key constraint fails (myblog.articles, CONSTRAINT articles_ibfk_1 FOREIGN KEY (userid) REFERENCES admindetails (id) ON DELETE CASCADE ON UPDATE CASCADE)
Help me please guys....
 
     
     
    