Zeki
Zeki

Reputation: 73

Getting data from several database table as an array with PHP

My Database Look Like This

I want to get all column1's data that has "asde" in its column2 and use them to create a dropdown list. How can i do that?

I used this

    $deneme = "SELECT column1 FROM table1 WHERE column2 LIKE '%INSE%'";
    $deneme2 = mysql_query($deneme);
    $deneme3 = mysql_fetch_array($deneme2);

Upvotes: 1

Views: 47

Answers (2)

Alex
Alex

Reputation: 8072

SQL:

$q = mysql_query("select column1, column2 from table where column2 LIKE '%asde%'");

Then use it for dropDownList options:

echo '<select name="fhdfh">';
while ($row = mysql_fetch_array($q, MYSQL_NUM))
    echo '<option value="'.$row[0].'" selected>'.$row[1].'</option>';
echo '</select>';

Upvotes: 1

Ronak Shah
Ronak Shah

Reputation: 1549

Try this

select distinct column1 from table where column2 = 'asde'

Upvotes: 0

Related Questions