Jump to content
php.lv forumi

foreach ar check box


vitao.web

Recommended Posts

Labdien!

 

Izmantoju līdz šim šādu kodu:

  <?php
       foreach($categories as $cat){
        echo "<option value='{$cat}'>{$cat}</option>";
       }
      ?>

 

Tagad radās vajadzība panākt to pašu, bet ar check box, kā to varētu panākt. Varbūt kādu piemēru varētu parādīt? Un vispār vai tas būtu labs veids?

Link to comment
Share on other sites

 <?php
       foreach($categories as $cat){
        echo "<input type=\"checkbox\" value='{$cat}' />{$cat}";
       }
   ?>

Tu domāji šādi?

 

Par pareizību, labestību nemācēšu teikt ! Manuprāt tas nekas traks nav, ja ciklā izvadi attiecīgus boxus, pēc vaidzības.

Edited by Kemito
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...