Jump to content

mysql search application


cybervanes

Recommended Posts

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";
}

 

Link to comment
https://forums.phpfreaks.com/topic/78714-mysql-search-application/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.