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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.