1

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);
1
  • 2
    Which part are you having trouble with? The query? Putting them into an array, or creating a dropdown list from the array? Please show what you've written so far so we can help you fix it. We're not here to write your whole script for you. Commented Apr 20, 2014 at 5:36

2 Answers 2

1

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>';
Sign up to request clarification or add additional context in comments.

6 Comments

I should have been more clear. I want to select them with for loop. I selected but when i try to echo them out i can't.
@user3552536 give us example of code that doesn't work
I deleted it because it didn't work. But i wrote similar to one that i used.
It says Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given on line 40 | Line 40-> $data = mysql_fetch_array($q);
Thanks a lot!. But there is one thing that i want to do. It's not that important like the one before. What if i want to do this for all 114 table. $q will be array. What about $row. Is will be like kind of multidimensional array?
|
0

Try this

select distinct column1 from table where column2 = 'asde'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.