html - mysql & php select * query not working -


i have table in db called sales. each row has value in column federal. want collect federals in array within code, doesn't work , dont know why... please help! thanks!

  <?php               $db = mysqli_connect("server", "usr", "pw", "db");                $federalres = $db->query("select * `sales` `state` = 'Österreich'"); //gets every row state = 'Österreich'                $federals = array(); // empty array collect federals                while ($row = $federalres->fetch_object()) {                 if (!in_array($row->federal, $federals)) { // check if federal in array                   array_push($federals, $row->federal); // adds federal array                 }               }                sort($federals); // sorts array alphabetically                foreach ($federals $key => $value): ?>                 <li><?php echo $value ?></li>               <?php endforeach; ?> 

you try like statement instead of =.

please try below code:

<?php   $db = mysqli_connect("server", "usr", "pw", "db");    $federalres = $db->query("select * `sales` `state` 'Österreich'"); //gets every row state = 'Österreich'    $federals = array(); // empty array collect federals    while ($row = $federalres->fetch_object()) {     if (!in_array($row->federal, $federals)) { // check if federal in array       array_push($federals, $row->federal); // adds federal array     }   }    sort($federals); // sorts array alphabetically    foreach ($federals $key => $value): ?>     <li><?php echo $value ?></li>   <?php endforeach; ?> 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -