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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:50:34+00:00 2026-06-13T23:50:34+00:00

Does someone figures out a way to make this code works even when MySQL

  • 0

Does someone figures out a way to make this code works even when MySQL subquery returns more than one result? It is working fine when the user has no event related to him, or when the user has one event related to him, but when a user is related to more than one event, the subquery returns more than one result and than the code gets nothing to work with.

$stmt = $db->prepare("SELECT * FROM events WHERE
                  id_events = ( SELECT id_events FROM relationship_events WHERE id_user = ?)");
$stmt->bindParam(1, $idUser);
$stmt->execute();

$rawTimeStamps = $stmt->fetchAll(PDO::FETCH_ASSOC);
$cleanDateArray = array();

foreach ($rawTimeStamps as $t) {
$rawDate = $t['start'];
$rawDate = getdate($rawDate);
$cleanDate = mktime(0,0,0,$rawDate['mon'],$rawDate['mday'],$rawDate['year']);
$cleanDateArray[] = $cleanDate;
}

for($list_day = 1; $list_day <= $days_in_month; $list_day++):

$calendar.= '<td class="calendar-day">';
    $timestamp = mktime(0,0,0,$month,$list_day,$year);
    if (!empty($cleanDateArray) && in_array($timestamp, $cleanDateArray)) {

    $date = getdate($timestamp);
    $time_start = mktime(0,0,0,$date['mon'],$date['mday'],$date['year']);
    $time_end = mktime(23,59,59,$date['mon'],$date['mday'],$date['year']);
    $stmt = $db->prepare('SELECT title FROM events WHERE start BETWEEN ? AND ?');
    $stmt->bindParam(1,$time_start,PDO::PARAM_INT);
    $stmt->bindParam(2,$time_end,PDO::PARAM_INT);
    $stmt->execute();
    $events = $stmt->fetch(PDO::FETCH_ASSOC);

    $calendar.= '<div class="day-number day-number-event"><a href="#">'.$list_day.'</a></div><p>'.$events["title"].'</p>';
    } else {
    $calendar.= '<div class="day-number day-number-noevent">'.$list_day.'</div><div id="calendar-events"></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-13T23:50:35+00:00Added an answer on June 13, 2026 at 11:50 pm

    Query should be SELECT * FROM events WHERE id_events IN ( SELECT id_events FROM relationship_events WHERE id_user = ?).

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

Sidebar

Related Questions

Hi all can someone please tell me what does this line of code do
Does someone know a simple way to set the default zoom and latitude/longitude with
Does someone know why this is not a strict quine ? _0='_0=%r;print _0%%_0';print _0%_0
hoping someone can help me out with this. I'm trying to figure out whether
I'm trying to figure out which is the more efficient way to get the
Does someone knows why the mysql_real_escape_string() function adds three backslashes before quotes, or double
Does someone know how to find the longest common subsequence of a set of
Does someone know why i never get the first value of my array? it
does someone know how to draw 3D surfaces and hide the invisible lines? I
does someone have an idea how to get the environment variables on Google-AppEngine ?

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.