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

  • SEARCH
  • Home
  • 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 6722137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:24:43+00:00 2026-05-26T09:24:43+00:00

Im trying to create a calendar application. I’ve got a problem with the way

  • 0

Im trying to create a calendar application.

I’ve got a problem with the way to echo dates WITH an event.

I’ve tried this:

$nuvarende_maned=date("m");
$sql=("SELECT * FROM kalender WHERE begivenhed_maned='$nuvarende_maned'");
$result=mysql_query($sql);
$count=mysql_num_rows($result);
$row=mysql_fetch_array($result);

echo "<div id='kalender'>";

for($a=1;$a<=date("t");$a++){

$dag_m_begivenhed = $row['begivenhed_dag'];

if($count>=1 && $dag_m_begivenhed == $a){
    echo "<div class='kalender_dag'><a title='$row[begivenhed_overskrift]' href=''>".$a."</a></div>";
} else {
    echo "<div class='kalender_dag'>".$a."</div>";
}
}

echo "</div>";

It’s printing one date with an event. I need some way if creating a while() loop. But I can’t figure out where to place it.
I’ve tried a while() inside of the for() but it doesn’t work.
I know I have the $row=mysql_fetch_array($result); in the beginning and that’s why I would always only have the first match from the database. I just did this to see if something came out of the DB.

  • 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-05-26T09:24:43+00:00Added an answer on May 26, 2026 at 9:24 am

    You’ll have to fetch all of the calendar events BEFORE going into your calendar generation loop. Right now, you only fetch the first row of the query results, and throw away the rest (mysql_fetch_array returns a single ROW as an array, not the whole result set).

    $events = array();
    
    $sql = "SELECT * FROM kalender WHERE begivenhed_maned='$nuvarende_maned'";
    $result = mysql_query($sql) or die(mysql_error());
    
    while($row = mysql_fetch_assoc($result)) {
       $events[$row['begivenhed_dag']] = $row;
    }
    
    for ($a = ...) {
       if (isset($events[$a])) {
           ... output whatever parts of $events[$a] you want
       }
    }
    

    Note that this doesn’t handle multiple events in a single day. If you need that capability, then you’ll have to modify the database fetch loop a bit, so it stores those multiple events in a sub-array.

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

Sidebar

Related Questions

I am trying to create a calendar view for events. Before my trials this
I'm trying to create a weekly calendar that looks like this: http://dhtmlx.com/docs/products/dhtmlxScheduler/sample_basic.html How can
I am trying to create a PHP script that will create a calendar event
I've got into a rather simple, yet annoying problem. I'm trying to create a
I'm trying to create a basic date-selector/calendar in wxPython. So far I've managed to
we are trying to create a calendar function in python. we have created a
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a small monitor application that displays current internet usage as percentage
I am trying to create a calendar using the Gallery widget. I have a
I'm trying to create a calendar in an HTML table design with CSS element

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.