samedi 1 avril 2017

dynamically generate html checkbox using php

I have a very small script that I am using to create dynamic content from a MySQL table. When I insert php into my code, it seems to overwrite the values.

My script is the following:

   <?php
    include 'auto_loader.php';
    include 'db.php';
    $database = new Database();
    $database->query('Select * FROM barber_dev.services');
    $rows = $database->resultset();
    foreach ($rows as $key => $value) {

      echo '
      <div class="label-container">
          <input type="checkbox" name="services[]" id="'+$rows['services']+'" value="HairCut">
          <label for="Haircut">Haircut</label>
      </div>
              ';
 }

     ?>

I would except to see about 10 checkboxes with the php rendering valid id values. What I get instead is 0 checkboxes and the actual values. I am probably missing something extremely basic, but any help would greatly be appreciated.

Thanks.




Aucun commentaire:

Enregistrer un commentaire