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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:23:33+00:00 2026-06-17T17:23:33+00:00

I am making an application that displays activities. Each activity has his own button.

  • 0

I am making an application that displays “activities”. Each activity has his own button. When you click on that button, you add that specific activity to your “guide”. The idea is that you can add one specific activity only once, so the button of that activity must disapear when it’s added to the guide. I can use a simple $(this).hide() in my javascript but that obviously doesn’t work when I refresh the page. So I guess i should make a check if the activity exists in de guide.

in the database I have 3 tables, 1: activity (with an ActivityID), 2: user (with a UserID) and 3: user_activity (with ActivityID and UserID, a linktable).

So the check must check if the ActivityID exists in the user_activity table, and that the UserID that belongs to that ActivityID in the user_activity table is the sames as the current users’ ID.

At this moment, I know how to check the current users UserID:

//userid
$sql = "SELECT * FROM user WHERE Username = '".$_SESSION['Username']."' ";
$stm = $db->prepare($sql);
$result = $stm->execute(array());
while($row = $stm->fetch(PDO::FETCH_ASSOC)) {
$userid = $row['UserID'];
}

But I don’t know how to check if the ActivityID already exists, and how I should make this
if else statement.

Ay the moment I use this script to display the activity (incl. the button)

$sql = "SELECT * FROM activity";
$stm = $db->prepare($sql);
$result = $stm->execute(array());   

while($row = $stm->fetch(PDO::FETCH_ASSOC))
{
    echo '<div id="activity'.$row['ActivityID'].'">';
    echo '<img src="data:image/jpeg;base64,' . base64_encode( $row['ActivityIMG'] ) . '" >', '<br>';
    $instantguide = $row['ActivityID'];
    echo '<input type="button" class="addActivity" onclick="MakeRequest(' . $instantguide . ')" value="Activiteit toevoegen" data-activity="' . $row['ActivityID'] . '">';
    echo '</div>';
}
  • 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-17T17:23:34+00:00Added an answer on June 17, 2026 at 5:23 pm

    You need a LEFT JOIN to see what activities are already on

    SELECT a.*, ua.ActivityID as added 
    FROM activities a LEFT JOIN user_activity ua 
        ON a.ActivityID=ua.ActivityID AND UserID=:userid
    

    So you’ll have an additional added field in the resultset, filled with an id if it is already chosen or empty otherwise

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an application that recovers lottery numbers and displays them in a window.
I'm making an application that contains button's and those buttons control an embedded browser.
I'm working on making a website/web application that displays images every 5 or so
I am making an application that displays a picture of a room. When the
I am making an application that has a timer. I count the minutes and
I'm making an application that parses text and images from the Internet and displays
I am making an application in android. in first activity its displays list of
I'm making an application that should be used in a store that displays product
I am making an application that accepts a TCP Socket connection and displays the
I am making an application that involves controlling Safari from Applescript. Is there a

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.