Hi my program should be able to draw the SQL count from a certain table, and generate the number of textbox for the counted number. 

What i actually want is, based on the alphabet valued button I click, show the number of textboxes for the items that starts with the alphabet button clicked. 

```
<button type="submit" name="sort" id="S" value = "S" onclick="<?php $alphabet='S'; ?>">S</button>

<?php $query = "select count(*) from product where productname like '$alphabet%' ";
                $result = mysqli_query($dbconn,$query);
                while($row= mysqli_fetch_array($result)) {
                $count=$row['count(*)'];                    
                }
for($counter = 0; $counter < $count; $counter++){ //Create text boxes and add to cart buttons
                echo "<br>";
                echo "<br>";                  
                echo "<label>Product ID: </label><input readonly type='text' name='productname' id=''><br>";
                echo "<label>Product Name: </label><input readonly type='text' name='opening' id='' >"
                    ."<button type='button' class='deliver' id='' onclick=''>Add To Cart</button><br>"
                    ."<button type='submit' class='deliver' id='viewcart' onclick='window.location.href='BACart.php';'>View Cart</button><br>";                                      
                echo "<label>Quantity: </label>";
                echo "<button type='button' class='quantityaddsub' id='sub' onclick='quantitysub($counter)'>-</button>";
                echo "<input type='text' class='quantity' name='' id='quantity".$counter."' value=0>"; 
                echo "<button type='button' class='quantityaddsub' id='add' onclick='quantityadd($counter)'>+</button><br> ";
            }?>

```

I find it really tough to do so. Is my method correct, or is there a easier way to do it? Or do i have to use AJAX to call our php function in javascript as I have read elsewhere..?