Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:06:00+00:00 2026-06-11T02:06:00+00:00

I am trying to exclude more than one ID from a select list that

  • 0

I am trying to exclude more than one ID from a select list that is populated by a foreach loop:

$types = new Type();
$types->where('id !=', 13)->order_by('name')->get();
$data['types'] = $types;

<select class="styled" name="form[type_id]">
<option value="0"> - select one - </option>
<?php foreach ($types as $t): ?>
<option value="<?=$t->id?>" <?=check_selected($t->id, $i->type_id)?>><?=$t->name?></option>
<?php endforeach; ?>
<option value="13" <?=check_selected(13, $i->type_id) ?>>Other</option>
</select>

So at the moment it will exclude ID 13 (and add it manually to the bottom), but how do I add more IDs to be excluded?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:06:01+00:00Added an answer on June 11, 2026 at 2:06 am

    try this:

    ...
    $exclude = array(13,25);// add IDs to exlude
    ....
    <?php foreach ($types as $t): ?>
       <?php if(!in_array($t->id, $exclude)){ ?>// if the ID is in the exlude array don't add it
          <option value="<?=$t->id?>" <?=check_selected($t->id, $i->type_id)?>><?=$t->name?></option>
       <?php } ?>
    <?php endforeach; ?>
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select all dom elements that have id=mydiv but exclude the ones
I'm trying to exclude a bunch of results from a database SELECT using the
I'm trying to exclude a post from loop like: query_posts(posts_per_page=5&cat=1, -15&post__not_in = 1); However,
In Django, I am trying to derive (subclass) a new form from ModelForm form
I'm trying to exclude some data from a string using regex. var match =
I'm using MVC 3, and I'm trying to exclude some fields from validation in
I'm trying to order a grouped resultset. Problem is that one of the join
I am trying to create a SQL query that will select everything shown...but I
I am trying to exclude a directory with ISAPI-Rewrite (note: this is a windows/iis
I am following the guide at this site and trying to exclude databases with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.