选择下拉列表中选择的名称

Query for select God from God table

$sth =$dbh->prepare("SELECT god_id,god_name_ml,god_name_en,image,info_ml,info_en,details_ml,
       details_en,rounds_ml,rounds_en,mantra_ml,mantra_en,display_order FROM god");
       $sth->execute();

Query for select deity from deity table.Here god_id is the foreign key from god table

   $stmt = $dbh->prepare("SELECT deity_id,god_id,deity_name_ml,deity_name_en,info_ml,info_en,details_ml,
      details_en,mantra_ml,mantra_en,display_order FROM deity
      WHERE deity_id = :deity_id");
    $stmt->bindValue(':deity_id',$deity_id,PDO::PARAM_INT);
    $stmt->execute();
    $result = $stmt->fetchAll();
    $temp_array=$result[0];
    $god_id=$temp_array['god_id'];

display code for displaying god in dropdown from god table

<?php while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
       <option value="<?php echo $row['god_id'];?>">
         <?php echo $row['god_name_en']; ?>
       </option>
       <?php } ?>
       </option>
   </select>

what I need is, in dropdown list the given god_id in god table is present in deity table make it as selected. only I need is selected Id's are selected

Just check both the id's are same or not, try this :

<?php while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
  <option <?php if($row['god_id'] == $god_id) { echo "selected='selected'"; } ?> value="<?php echo $row['god_id'];?>"><?php echo $row['god_name_en']; ?></option>
<?php } ?>
</option>
</select>

Try this:

<?php while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
  <option <?php if($row['id'] == $stmt->god_id) { echo "selected='selected'"; } ?> value="<?php echo $row['god_id'];?>"><?php echo $row['god_name_en']; ?></option>
<?php } ?>
                                          </option>
                                        </select>

As you write each option compare whether God_I'd from God table matches the god_ID of the current option. If it does append the text "selected" after the value.

So the selected option will look something like

<option value='1' selected>foo</option>