cybervanes Posted November 24, 2007 Share Posted November 24, 2007 I’m trying to build a search application for searching a mysql database full of different cars. I need to echo back all available manufactures names. Instead of having a combo box or dropdown box full for all the manufactures known to man I would like to fill the selections dynamically with what is actually available within the database. The problem I’m having with the below code is it echo’s back the ‘maketxt’ field for all units so I have 20 Subaru’s and 20 ford’s ect. All I need is one name per manufacturer for the component. Probably the way to go would be to fill an array with the results of the query, and then run an “if statement” to check if a particular value is in the array, then echo out my own name. but I’m still not familiar with how PHP and arrays work. If you have any ideas they would be most appreciated! Have A Great Day! the code: $query = "SELECT * FROM vehicles WHERE cidlotd = \"$dealerId\""; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { echo "{$row['maketxt']} <br>"; foreach($a = array_fill(0,1,$row['maketxt']); { } } if(in_array('kia',$rows)){ echo "worked"; }else{ echo "nokia"; } Quote Link to comment https://forums.phpfreaks.com/topic/78714-mysql-search-application/ Share on other sites More sharing options...
fenway Posted November 25, 2007 Share Posted November 25, 2007 GROUP BY? Quote Link to comment https://forums.phpfreaks.com/topic/78714-mysql-search-application/#findComment-398466 Share on other sites More sharing options...
wsantos Posted November 25, 2007 Share Posted November 25, 2007 It would be always helpful to post your db structure...anyway as fenways note $query = "SELECT * FROM vehicles WHERE cidlotd = \"$dealerId\" GROUP BY brand"; Quote Link to comment https://forums.phpfreaks.com/topic/78714-mysql-search-application/#findComment-398522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.