Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8962603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:09:53+00:00 2026-06-15T16:09:53+00:00

I have this simple PHP code: <?php $con = mysql_connect(localhost,root,); if (!$con) { die(‘Could

  • 0

I have this simple PHP code:

 <?php
 $con = mysql_connect("localhost","root","");
 if (!$con)
 {
     die('Could not connect: ' . mysql_error());
 }
 mysql_select_db("boxcar", $con);
 echo "<form>";
 echo "<select>";
 echo "<option>--Select Brand--</option>";
 $result = mysql_query("SELECT * FROM cars");   
 while($row = mysql_fetch_array($result))
 {  
     echo "<option value=".$row['Brand'].">".$row["Brand"]."</option>";
 }
 echo "</select><br/><br/>";
 echo "<input type='button' name='submit' value='Search'/>"
 echo "</form>";
 mysql_close($con);
 ?> 

I’m new at this and just trying to build a advanced search function for variety of car models by the use of drop-down menus. I just want to have every car brand name as a parent category show only once on the dropdown list. I’m currently showing duplicated brand names because I have different car models with the same brand name.


In addition to that, I would like to have the 2nd dropdown menu for car models show the list of car models that correspond to the selected parent category(car brand) only and do not show all car models from database.

I currently have this code and the car models dropdown list show all models from database:

//--------Get Car Brands----------
$result = mysql_query("SELECT DISTINCT cars.brand FROM cars ORDER BY brand ASC");
while($row=mysql_fetch_array($result)){
echo "<option value=".$row['brand'].">".$row["brand"]."</option>";}
echo "</select>&nbsp;&nbsp;<select class='model'>";

//--------Get Car Models----------
echo "<option>--Select Model--</option>";
$result = mysql_query("SELECT DISTINCT cars.model FROM cars ORDER BY model ASC");
while($row=mysql_fetch_array($result)){
echo "<option value=".$row['model'].">".$row["model"]."</option>";}
echo "</select><br/><br/>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:09:54+00:00Added an answer on June 15, 2026 at 4:09 pm

    Try using

    SELECT * FROM car GROUP BY car.Brand

    or

    SELECT DISTINCT car.Brand FROM car;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this simple code to load data from other php page using get
Hi i have this simple code: var datastring=123; $.ajax({ url: 'actualizarimagen.php', type: 'post', dataType:
I have this simple code that is working fine in every browser, but NOT
I have this simple PHP code: $query = mysql_query(SELECT `title`, `url_title` FROM `fastsearch` WHERE
I have this simple code in php: <?php header(Content-type: application/vnd.ms-word); header(Content-Disposition: attachment;Filename=kid_tag.doc); echo '<table
i have this simple php code and want to use this code in a
I have this very simple php code: $xml=simplexml_load_file('abc.xml'); echo $xml; It shows only blank
I currently have this piece of code: NSString *strURL = [NSString stringWithFormat:@http://www.sample.com /phpFile.php?firstname=%@,txtfirstName.text]; NSString
Possible Duplicate: Check if a variable is empty Simple PHP question: I have this
I have a site with this simple structure: \public_html {files}.php \files \es For the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.