Question: I am new on php and I have create a project that bring a data from the database as the user selection , and when the execution of the project it occurred an error at an method , and I didn't now how to solve it .
hear is the php code : - 

```
     <?php

      $db = new PDO('sqlite:dinner.db');
      $meals = array('breakfast','lunch','dinner');

      if(in_array( $_POST['meal'], $meals)){

     $stmt = $db->prepare('SELECT dish,price FROM meals WHERE meal LIKE ?');
     $stmt->execute(array($_POST['meal']));
    $rows = $stmt->fetchAll();

      if(count($rows) == 0){
         print "No dishes available now";
      } else {

          print "<table><tr><th>dish</th><th>price</th></tr>";
          foreach($rows as $row) {
           print "<tr><td>$row[0]</td><td>$row[1]</td></tr>";
      }
          print "</table>";
      }
} else {
   print "Unknown meal";
  }

  ?>

```

and that is the html page code : 

```
          <html>
         <head>
         </head>
         <body>

      <form method="post" action="test.php">
      <lable>Select the meal to see all the available dishes:
      <input type="text" name="meal">

      </lable><input type="submit" value="Ok">
     </form>

   </body>
  </html>

```

and that is the output at the browser: - [enter image description here](https://i.stack.imgur.com/3GQFt.png)

Answer: 
You can use index to change the value of each button. See if this helps.

```js
for (var i = 0; i <= 11; i++) {
        var r = $('<input type="button" value="new button ' + i + '" style="margin-left:10px; margin-top:5px;"/>');
        $("#sth").append(r);
}
$("#sth").css({ width: '300px', 'padding-top': '10px', 'padding-bottom': '10px', 'padding-left':'10px' });
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id='sth'></div>
```
You should change your string here : 

```
$('<input type="button" value="new button" style="margin-left:10px; margin-top:5px;"/>');

```

For something like this : 

```
$('<input type="button" value="new button-' + i + '" style="margin-left:10px; margin-top:5px;"/>');

```

So you will have : new button-1, new button-2 ....
Hope that help