While fetching drop down value Query Issue - not executing

Dear All,

$std=$row['std_id'];
$quer3="SELECT * FROM `std_master`
                inner join products on products.std_id=std_master.std_id where products.school_id=:id  ";
$query = $conn->prepare($quer3);
                                
$query->bindParam(':id', $schid);
                                
$result= $query->execute();
                                
echo "  <select class='select2 form-control custom-select' name='stdname' id='stdname'  >";
                                
foreach ($result as $noticia)
 {
      if($noticia['std_id']==@$std)
          {
                                        
                 echo "<option selected = 'selected' value='$noticia[std_id]'>$noticia[std_name]</option>"."<BR>";
                                        
           }
            else
           {
                  echo  "<option  value='$noticia[std_id]'>$noticia[std_name]</option>";
           }
 }
echo "</select>";

this is my code while running it will execute infinity times and not fetching output…

what i did wrong…?

thanks

Why are you suppressing anything?

How do you know it will execute “initinity times”? Foreach loops don’t cause infinite loops. So what is actually happening?

Sponsor our Newsletter | Privacy Policy | Terms of Service