Mysql php select Columns after selecting from dropdown -


i need thing regarding mysql , php.

i have following dropdown:

    <select>   <option value="volvo">volvo</option>   <option value="saab">saab</option>   <option value="mercedes">mercedes</option>   <option value="audi">audi</option> </select> 

and database car models.

i need echo select database based on value selected dropdown.

so if user in website selects volvo recieve selection mysql database following info:

volvo s30 volvo s60 volvo s90 etc. 

edit

the select :

select imagename, imageurl pics carmaker=volvo

but don`t know how make select conditioned users selected option.

i try give quick help.

first have set name attribute @ html select.

<select name="type">   <option value="1">volvo</option>   <option value="2">saab</option>   <option value="3">mercedes</option>   <option value="4">audi</option> </select> 

then in file form redirects you:

$connection = mysqli_connect('localhost', 'root', 'your_password', 'your_database'); mysqli_set_charset($connection, 'utf8'); if (!$connection) {     die("database connection failed: " . mysqli_error()); } $car_type = (int)$_post['type'];    //code user input validation , sanitization $query = "select imagename, imageurl pics carmaker = '$car_type';"; $result = mysqli_query($connection, $query); if(!$result) {     die("sql error: " . mysqli_error($connection); }  //then can make loop take data 1 one  while ($row = mysqli_fetch_array($result)) {     echo '<p>'.$row['imagename'].' '.$row['imageurl'].'</p>'; } 

for start try use queries using mysqli_* functions (not mysql_*). try learn pdo or similar. important read tutorials explaining server side user input validation , sanitization.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -