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 8206945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:50:45+00:00 2026-06-07T08:50:45+00:00

I’ve been at this for hours and i have gotten a slight break through,

  • 0

I’ve been at this for hours and i have gotten a slight break through, however i am at a stand still at the moment. I have a SQL Database that store vehicle information, such as make, model and year. What i want to do is allow users to modify the query and only display specific results.

I understand how to display all the records at once but what i want to add is when the user selects say for example the make as “Toyota” i want only that specific make to appear. I did reach some where in this, by using this code:

<form method="post" action=""> 
 <div id="search_query" >
     Make 
    <select name="make" size="0">
    <option value="honda">Honda</option>
  <option value="toyota">Toyota</option>
  <option value="nissan">Nissan</option>
    </select>

     <input type="submit" name="submit" value="submit">

 </div>
 </form>     

<?php

    $db_con = mysql_connect('localhost', 'root', '');

    if (!$db_con) {
        die('Could not connect: ' . mysql_error());
    }

    mysql_select_db('my_db', $db_con);

    $make = mysql_real_escape_string($_POST['make']);

    $sql = sprintf("SELECT * FROM chjadb_vehicles WHERE v_make= '$make' ");


    $result = mysql_query($sql);


    echo "<table width= 970 border=1>
         <tr>
           <th width='120' scope='col'>Image</th>
           <th width='170' scope='col'>Details</th>
           <th width='185' scope='col'>Seller</th>
           <th width='126' scope='col'>Price</th>
         </tr>";
    while($row = mysql_fetch_array($result))
      { 
         echo "<tr>";
           echo "<td> <img src=" .$row['v_image']. " width =200 height = 130>" . "</td>";
           echo "<td>". $row['v_year'] . "&nbsp;" . $row['v_make'] . "&nbsp;". $row['v_model'] . "&nbsp;". $row['b_type']. "</td>";
           echo "<td>". $row['user_id'] ."</td>";
           echo "<td>". $row['v_price'] ."</td>";
         echo "</tr>";
      }
       echo "</table>";

     mysql_close($db_con);
    ?>

however when i run the page initially i get this error: “Notice: Undefined index: make in C:\xampp\htdocs\carhuntja.com\buy_a_car.php on line 62”

i did some research and realized that this was happening because i had no make value set, what i wish to do here is at the start of going to that page i want all vehicles to be displayed.

  • 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-07T08:50:47+00:00Added an answer on June 7, 2026 at 8:50 am

    The problem is that the query is being sent before the user chooses a make. To fix this, you need check that the user has actually submitted the form by enveloping your PHP code in if(isset($_POST['submit'])) (“submit” is used because that is the name of your submit button).

    //place connection code here (do not query the database yet)
    
    if(isset($_POST['submit']))
    {
       //all of the database retrieval code
    }
    else
    {
      $query_makes = "SELECT v_make FROM chjadb_vehicles";
      $result_makes = mysqli_query($query_makes);
      echo "Please choose a make."
      //echo opening select tag
      while($row = mysql_fetch_array($result_makes))
      {
         //echo each option tag
      }
      //echo ending select tag
    }
    

    Also, you are missing a slash in the self-contained input tag.
    Finally, you should use MySQLi functions because MySQL functions are deprecated in PHP.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a reasonable size flat file database of text documents mostly saved in
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.