[selectbox with multiple columns from mysql database](https://stackoverflow.com/questions/15204674/selectbox-with-multiple-columns-from-mysql-database)

The following code was the winning code from zgr024

```
       <?php 
    include '../config.php';
    $sql = "SELECT * FROM megabase";  
    $resultaat = mysql_query($sql) or die (mysql_error());  
    $domains = array();
    while ($row = mysql_fetch_array($resultaat))       
    { 
       if (!empty($row['domeinnaam1'])) $domains[] = $row['domeinnaam1'];
       if (!empty($row['domeinnaam2'])) $domains[] = $row['domeinnaam2'];
    }
?>

   <select size="1" name="domeinnaam">
<?php
    foreach ($domains as $domain)
    {
        echo "<option>$domain</option>";
    } 
?>
    </select>

```

But this code resulted in an expected error on the next page where i have the following code.

```
    <?php 

     //MySQL Database Connect
     include 'config.php';

    $domeinnaam=$_POST['domeinnaam']; 

    $data = 'SELECT * FROM megabase WHERE domeinnaam = "'.$domeinnaam.'"'; 
      $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error()); 
      $data2 = mysql_fetch_array($query); 

    ?> 

```

How do i change the last code to work with the first code:

I have tried:

```
        <?php 

         //MySQL Database Connect
         include 'config.php';

        $domeinnaam=$_POST['domeinnaam'];
       $domeinnaamquerry='domeinnaam1'.'domeinnaam2'.'domeinnaam3'.'domeinnaam4'.'domeinnaam5'.'do meinnaam6'.'domeinnaam7'.'domeinnaam8'.'domeinnaam9'.'domeinnaam10';

        $data = 'SELECT * FROM megabase WHERE $domeinnaamquerry = "'.$domeinnaam.'"'; 
          $query = mysql_query($data) or die("Couldn't execute query. ".             mysql_error()); 
          $data2 = mysql_fetch_array($query); 

        ?> 

```

But i receive the following error:
Couldn't execute query. Unknown column '$domeinnaamquerry' in 'where clause'

Okey got it working now it is sloppy but working thanks everyone for your input it was helpful. and thanks for the warnings. 

here is the code

```
     <?php 

      //MySQL Database Connect
      include 'config.php';

     $domeinnaam=$_POST['domeinnaam']; 

     $data = 'SELECT * FROM megabase WHERE domeinnaam1="'.$domeinnaam.'" OR domeinnaam2="'.$domeinnaam.'" OR domeinnaam3="'.$domeinnaam.'" OR domeinnaam4="'.$domeinnaam.'" OR domeinnaam5="'.$domeinnaam.'" OR domeinnaam6="'.$domeinnaam.'" OR domeinnaam7="'.$domeinnaam.'" OR domeinnaam8="'.$domeinnaam.'" OR domeinnaam9="'.$domeinnaam.'" OR domeinnaam10="'.$domeinnaam.'"    '; 
       $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error()); 
       $data2 = mysql_fetch_array($query); 

     ?> 

```