0

Hi Am trying to read the table name from the dropdown but am unable give the name option name. Here is my code.

 <div class="form-group">
          <label class="control-label col-sm-2" for="email">Enter number of titles:</label>
              <div class="col-sm-10">
                <select>
                  <?php 
                     include 'config.php';
                     $query="show tables";
                     $result_query=mysqli_query($conn,$query);
                      while($row=mysqli_fetch_array($result_query))
                       {
                          echo "<option>$row[0]</option>";
                       }
                  ?>
                 </select>
              </div>
        </div>

How can I give the option value or name as there are 10 tables I need to read the table name once the table is selected

Thank you

1 Answer 1

1

replace

echo "<option>$row[0]</option>";

to

echo "<option value='{$row[0]}'>{$row[0]}</option>";
Sign up to request clarification or add additional context in comments.

2 Comments

Yaa I got it sorry for question but how can I store it in variable
in PHP or JS? in PHP you must use FORM tag and set attr "name" to SELECT tag(<select name="table">)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.