Jump to content

How to fetch from mysql and use output in table


spacerman

Recommended Posts

My idea is to hava a database with movie genres to pick from a dropdown(this works). And when genre is chosen a list of movies  of that genre will show up in my table.

 

Here is the code for the dropdown that works...

 

$host="localhost"; // Host name

$username="xxx"; // Mysql username

$password="xxx"; // Mysql password

$db_name="per_film"; // Database name

$tbl_name="sjanger"; // Table name

 

 

$sql="SELECT id, Alle FROM sjanger ORDER BY Alle";

$result=mysql_query($sql);

 

$options="";

 

while ($row=mysql_fetch_array($result)) {

 

    $id=$row["id"];

    $sjanger=$row["Alle"];

    $options.="<OPTION VALUE=\"$id\">".$sjanger.'</option>';

   

}

?>

 

<form = method="post">

<SELECT NAME='filmer' onchange="document.getElementById('ex').innerHTML = this.value;" >

<OPTION VALUE=0>Alle

<?=$options?>

</SELECT>

</form>

 

Now the problem is to use the dropdown inuput to get results back and put into table....

Can anyone help me with this............

 

Ok. I'll try to explain better.

I have a database that holds movie genres(sjanger).

I have a dropdown menu connected to that database.

I want the user to choose a genre from the dropdown menu, and a list of movies in that genre is shown in a table.

As default the list should show all movies.

This was supposed to be as easy as possible- just an inventory of my movies.

 

So my main question is: when someone make a choise from the dropdown, how do I show the movies in the list when that genre is chosen?

 

Appreciate your help...

Archived

This topic is now archived and is closed to further replies.

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