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 8137053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:57:49+00:00 2026-06-06T10:57:49+00:00

I had made three tables. Table1=users .And the column names are userid (auto_increment) and

  • 0

I had made three tables.

Table1=users.And the column names are userid (auto_increment) and username.
Table2=hobbies. column names are hobbyid (auto_increment) and hobbyname.
Table3=users_hobbies. column names are FK_userid and FK_hobbyid.

Now hobbyname has cricket,football,volleyball.
During sign-up user selects only cricket and football and I store it in $_SESSION[‘hobby_id’] associative array.

But in profile he/she wants to add some more hobbies.

So I want to display list of hobbies which are not equal to $_SESSION[‘hobby_id’].

This , ofcourse didn’t work:

foreach($_SESSION['hobby_id'] as $k=>$v)
{

  $query="select hobbyid,hobbyname from hobbies where hobbyid!= $v";
}  
Output was football,volleyball and cricket,volleyball....but i wanted only volleyball

So i want that

$query="select hobbyid,hobbyname from hobbies where hobbyid!=(multiple values of session hobby id)";

What code will I have to enter to get desired result(only volleyball)?

  • 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-06T10:57:52+00:00Added an answer on June 6, 2026 at 10:57 am

    remove foreachloop and use NOT IN comparision in MySQL:

    $query="
        SELECT hobbyid,hobbyname
        FROM hobbies
        WHERE hobbyid NOT IN (" . implode(',', $_SESSION['hobby_id']) . ")
    ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had made a Jigsaw Puzzle in RaphaelJS but found that it did not
I had made changes in a folder called branch, and now that its working
I had made a windows service in visual studio 2008 in C#. inside the
EDIT: I had made a mistake during the debugging session that lead me to
I was creating a module and had made a typo and then got a
Application_Error is not firing after publishing web site i had also made custom error
I Made label to had value from database and linked it . but the
I made changes to some files i had in a project (they were auto
I made an algorithm for sorting but I then I thought perhaps I had
i made the connection between emulatore and physical device via USB.I had follow the

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.