Toon posts:

[PHP] Jaren selectie functie

Pagina: 1
Acties:
  • 32 views sinds 30-01-2008

Verwijderd

Topicstarter
Geachte lezer,

Ik heb een kleine functie geschreven, zodat ik een selectbox krijg met bijvoorbeeld 3 keuzes voor een jaartal. Beetje lastig uit te leggen, hij is niet zo ingewikkeld, maar hij werkt niet. Hij geeft helemaal geen waardes tussen de <option> tags.

Misschien kan ik hem beter even laten zien, dat is wat duidelijker hoop ik:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
function genYears($naam, $aantalvooruit)
{
    $huidigjaar = date("y");
    $aantalvooruit = ($huidigjaar + $aantalvooruit);
    $output = "<select name=\"$naam\">";
    for($d=$huidigjaar;$d==$aantalvooruit;$d++)
    {
        $output .= "<option value=\"$d\">20".$d."</option>";
    }
    $output .= "</select>";
    return $output;
}

$naam = naam van de selectbox
$aantalvooruit = het aantal jaren dat de functie bovenop het huidige jaar moet doen.

Dus met deze info:

genYears("test", "5")
Wil ik deze output hebben
code:
1
2
3
4
5
6
7
<select name="test">
   <option value="07">2007</option>
   <option value="08">2008</option>
   <option value="09">2009</option>
   <option value="10">2010</option>
   <option value="11">2011</option>
</select>


Ik hoop dat het duidelijk is, ik kom er niet uit....ik weet zeker dat ik iets over het hoofd zie...maargoed, alvast bedankt.

  • Greenstick
  • Registratie: Juli 2004
  • Laatst online: 07-12-2020

Greenstick

Groen als gras

Verwijderd schreef op maandag 12 maart 2007 @ 11:31:
PHP:
1
2
3
4
    for($d=$huidigjaar;$d==$aantalvooruit;$d++)
    {
        $output .= "<option value=\"$d\">20".$d."</option>";
    }
Moet het niet
code:
1
$d<$aantalvooruit
zijn? ;)

- 01000111 01101111 01010100 -
We love to think about the way things were,
but the time has come and I'm glad it's over


  • Snake
  • Registratie: Juli 2005
  • Laatst online: 07-03-2024

Snake

Los Angeles, CA, USA

PHP:
6
for($d=$huidigjaar;$d<=$aantalvooruit;$d++)

Going for adventure, lots of sun and a convertible! | GMT-8


Verwijderd

Topicstarter
right....ja dat was hem...dank u allen

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 20-11 11:59

NMe

Quia Ego Sic Dico.

Juist, gewoon even debuggen dus. :)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Dit topic is gesloten.