PHP Code With Filtered Dynamic Drop Down Menus

I am having a lot of trouble with my code, and I really don’t know what to do. I am building a gui for a fictitious car company, and on the gui, I have 5 drop down menus. They are make, model, year, mileage, and color. I am using phpMyAdmin and a mysql database. The information is loaded into the database. My final goal if for the user to select the options from the 5 drop down menus and then after clicking the submit button, the database should filter the results to match the choices chosen by the user. The results should then be echoed back to the gui so the user can see it. Basically, it is somewhat like cars.com. Here is my code

<?php if(isset($_POST['Make'])) { $Make = $_POST['Make']; $Model = $_POST['Model']; $Year = $_POST['Year']; $Mileage = $_POST['Maximum_Mileage']; $Color = $_POST['Color']; $dbhost = "instructdb1.aset.psu.edu"; //host $dbuser = "XXXX"; //username $dbpass = "XXXX"; //password $dbname = "XXXX"; // database name $dbconnection=mysqli_connect($dbhost, $dbuser, $dbpass) or die(mysqli_connect()); $db_selected=mysqli_select_db($dbname, $dbconnection); echo "connected to MySQL
"; $Query=("SELECT * FROM Inventory WHERE Make = '$Make' AND Model = '$Model' AND Year = '$Year' AND Mileage = '$Mileage' AND Color = '$Color'") or die (mysql_error()); $result = mysqli_query($Query) or die (mysqli_error()); while ($row = mysqli_fetch_array($result)) { echo "
"; echo $row['Make']. "-". $row['Model']. "-". $row['Year']. "-". $row['Mileage']. "-". $row['Color']; echo "
"; } } else { ?> Nomo Motors table{margin-left:0%;margin_right:0%;width:100%} td{font-size:36;color:Black;background-color:tan; text-align:center;border: 4px solid black;} th{font-size:18;color:Black;background-color:gray;text-align:center;border: 4px solid black;}
Nomo Motors
Make Ford Mercury Mazda Subaru Toyota Model Accord Taurus Millenia Forester Sable Focus Tracer Outback Ranger Camry Mountaineer Legacy Miata Explorer Cougar Civic Protege Impreza Mustang Sable Villager Grand Marqui Winstar F-150 Sable Year 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 Maximum Mileage 10,000 20,000 30,000 40,000 50,000 60,000 70,000 80,000 90,000 100,000 + Color Blue Yellow Silver Gold Red Purple Green Forrest Green Teal Navy Maroon
<input type="submit" name="s" value="Submit"
<? } ?>

The errors I get when I click the submit button are

Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in /pass/home/15/d/dco5044/www/phpdco5044/dco5044_NomoMotors.php on line 48
connected to MySQL

Warning: mysqli_query() expects at least 2 parameters, 1 given in /pass/home/15/d/dco5044/www/phpdco5044/dco5044_NomoMotors.php on line 59

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /pass/home/15/d/dco5044/www/phpdco5044/dco5044_NomoMotors.php on line 59

If someone could please help me, I would greatly appreciate it

Is this double posting? Also please do not post secure info such as database username/password etc. You’re posting this second time here.

Sponsor our Newsletter | Privacy Policy | Terms of Service