Jump to content

Recommended Posts

Hi,

I am a newbie and i have a question:

 

I have made a while loop that puts status on free, occupied or option.

The question is if i for example dates 3-10 4-10 5-10 6-10,  want to set 3-10 start.gif and 6-10 end.gif and ofcourse the 4-10 5-10 occupied?

 

Kind regards!

 

The script:

 

mysql:

 

    public function getDataStatusByAcconr($acconr,$year,$month)

    {

        $query = mysql_query("SELECT calender.day as day, calender.status as status FROM `calender` left join accos on calender.acco_id = accos.acco_id

where

accos.acconr = '$acconr'

and

calender.year = '$year'

and

calender.month = '$month'

order by calender.day");

        $result2 = array();

 

        while ($array = mysql_fetch_array($query, MYSQL_ASSOC)) {

            $result2[] = $array;

        }

        return $result2;

 

    }

 

While loop:

 

while ( $day_num <= $days_in_month ) {

 

$objViewAdmin = new Model();

$resultset = array();

$resultset = $objViewAdmin->getDataStatusByAcconr($acconr,$year,$month);

 

$days = '';

$status = '';

foreach ($resultset as $value){

if($day_num == $value['day']){

$days .= $value['day'].','.$value['status'].'|';

}

}

  echo '<pre>'.print_r($days,true).'</pre>';

 

  if (preg_match("/$day_num\,/", "$days|")) {

if (preg_match("/\,0/", "$days|")) {

echo "<td style=\"background-image:url('images/free.jpg');\"> <a href=\"$day_num\">$day_num</a> </td>";

}

if (preg_match("/\,1/", "$days|")) {

echo "<td style=\"background-image:url('images/occupied.jpg');\"> $day_num </td>";

}

if (preg_match("/\,3/", "$days|")) {

echo "<td style=\"background-image:url('images/option.jpg');\"> <a href=\"$day_num\">$day_num</a> </td>";

}

}

else{

echo "<td style=\"background-color:";echo "#008000"; echo "\"> $day_num </td>";

}

$day_num++;

$day_count++;

 

if ($day_count > 7){

echo "</tr><tr>";

$day_count = 1;

}

}

 

Link to comment
https://forums.phpfreaks.com/topic/268008-calendar-start-end/
Share on other sites

" $result2 = array();

 

        while ($array = mysql_fetch_array($query, MYSQL_ASSOC)) {

            $result2[] = $array;

        }

"

u dont need second variable

$result2 = array();
        while ($result2[] = mysql_fetch_array($query, MYSQL_ASSOC));

"want to set 3-10 start.gif and 6-10 end.gif "

u can made some config , like

$img_conf ['3-10'] = 'start.gif'

and then call it

$img = isset($img_conf [$variable]) ? $img_conf [$variable] : null;

Link to comment
https://forums.phpfreaks.com/topic/268008-calendar-start-end/#findComment-1375388
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.