Jump to content

Month color problam code included


redarrow

Recommended Posts

 

advance thank you.

 

my if($month==$i wont let the month off january go red why please cheers.

 

<?php

echo "

<html>

<head>

<title> my month</title>

</head>

<body>";

$month=array(1=>"january","febuary","march","april","may","june","july","august","september",
"october","november","december");

$today=time();

$f_today=date("d-M-Y",$today);
$g_month=date("n",$today);

echo "<br><br> Today is $f_today <br><br>";

echo " <form method='POST' method=' '>";

echo"<select name='month'>";

for($i=1; $i<=12; $i++){

echo"<option value='$i'>";


if($month==$i){

$month="<font color='red'>$month</font>";

}
echo "{$month[$i]}</option>";

}

echo "<form>

</body>

</html>";


?>

Link to comment
https://forums.phpfreaks.com/topic/141943-month-color-problam-code-included/
Share on other sites

Still does not make the month off January red in the select box of months mate cheers.

 

I want the current month off January, the color red cheers...

 

current code

<?php

echo "

<html>

<head>

<title> my month</title>

</head>

<body>";

$month=array(1=>"january","febuary","march","april","may","june","july","august","september",
"october","november","december");

$today=time();

$f_today=date("d-M-Y",$today);
$g_month=date("n",$today);

echo "<br><br> Today is $f_today <br><br>";

echo " <form method='POST' method=' '>";

echo"<select name='month'>";

for($i=1; $i<=12; $i++){

echo"<option value='$i'>";


if($month[$i]==$i){
   
   $month="<font color='red'>$month</font>";

}
echo "{$month[$i]}</option>";

}

echo "</form>

</body>

</html>";


?>

 

still got no color any reason mate?

<?php

echo "

<html>

<head>

<title> my month</title>

</head>

<body>";

$month=array(1=>"january","febuary","march","april","may","june","july","august","september",
"october","november","december");

$today=time();

$f_today=date("d-M-Y",$today);
$g_month=date("n",$today);

echo "<br><br> Today is $f_today <br><br>";

echo " <form method='POST' method=' '>";

echo"<select name='month'>";

for($i=1; $i<=12; $i++){

echo"<option value='$i'>";


if($month[$i] == $g_month)
{
   
   $month[$i]="<font color='red'>{$month[$i]}</font>";

}
echo "{$month[$i]}</option>";

}

echo "</form>

</body>

</html>";


?>

Hi,

the prob is in HTML styling.

 

To get colored options the method is something like:

 

<select>

<option style="color:red">Item1</option>

<option style="color:green">Item2</option>

</select>

 

 

so now u should use:



if($month[$i] == $g_month)
{
   echo "<option value='$i' style=\"color:red\">";
}
else
{
   echo "<option value='$i' style=\"color:any_color\">";
}
echo "$month[$i] </option>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.