<div class="clear">
    <?php foreach ($search as $s) : ?>
        <div class="icon" id="search_<?php echo htmlspecialchars($s['id']); ?>">
            <div class="content">
                <?php echo htmlspecialchars($s['word']); ?><br />
                <?php echo htmlspecialchars($s['total']); ?>
            </div>
            <div class="action">
                <a href="javascript:delete_search(<?php echo htmlspecialchars($s['id']); ?>);">Delete</a>
            </div>
        </div>
    <?php endforeach; ?>
</div>

<script type="text/javascript">
    function delete_search(id)
    {
        if (confirm('Are you sure?'))
        {
            data = {};
            
            if (typeof id !== "undefined")
            {
                data.id = id;
            }
            
            $.post('search/delete', data,
                function(data, status) {
                    if (data.error != '')
                    {
                        alert(data.error);
                    }
                    else
                    {
                        if (id)
                        {
                            $('#search_' + id).remove();
                        }
                        else
                        {
                            $('.icon').each(function() {
                                $(this).remove();
                            });
                        }
                    }
                }, 'json');
        }
    }
</script>
