Doubt to get the id of a different table Php and MySql [closed]

0

How do I save the id of a different table inside a select?

Code below

<div class="medium">
            <span>
                <select name="turma">
                    <option>Selecione a Sala</option>
                    <?php
                    do {
                        ?>
                        <option> <?php echo $exibe['sala'] ?> </option>
                    <?php } while ($exibe = mysql_fetch_assoc($sql)) ?>
                </select>
                <span class="icon-place"></span>
            </span>
        </div>

Class is a different table, the complete form is for a student's registration!

    
asked by anonymous 17.09.2016 / 15:04

1 answer

1

Places the value of the option with the class id. Without seeing the bank is difficult, but I suppose it is like this:

<option value="<?php echo $exibe['id_turma'] ?>"> <?php echo $exibe['sala'] ?> </option>

I also suggest you use while instead of do while

<select name="turma">
    <option>Selecione a Sala</option>
    <?php
    while ($exibe = mysql_fetch_assoc($sql)) { ?>
        <option value="<?php echo $exibe['id_turma'] ?>"> <?php echo $exibe['sala'] ?> </option>
    <?php } ?>
</select>
    
17.09.2016 / 18:58