- Impact
- 0
hello to those reading this, im new to coding and have a lot to learn but right now what im trying to do is set up a database that can be searched through the use of check box options. when i try my best to code it i get a blank screen(if it's not a error message) here's an idea of what i have so far......
Database
table name: DVD's
columns: D_id|Name |Type |Rating
Row 1: 1 |super bad|Movie|R
HTML
<form action="searchresults.php" method="post">
<input type="checkbox" name="Type[]" value="series" />Series
<input type="checkbox" name="Type[]" value="movie" />Movie
<input type="checkbox" name="Rating[]" value="R" />R
<input type="checkbox" name="Rating[]" value="PG 13" />PG 13
<input type="submit" value="Submit" />
</form>
PHP
<?php
$con=mysql_connect("localhost","username","password");
mysql_select_db("database", $con);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$Type = array("Series", "movie");
$result = mysql_query("SELECT * FROM DVD's");
?>
this is where im stuck or confused or just lack experience to figure it out, i tired different methods to finish off that php code with no luck but what i want to happen is the ability to use the checkbox options to find all movies that match your choices. i kno im doing something wrong just cant figure it out, i even tried the mysql_fetch_array() but i get back error message saying it's not a valid MYSQL result. can anybody please help me(if you need a better idea of what i want to do, it would be just like the search page on animenewsnetwork website for their search by genre option using checkbox to find the list of anime based on your choices.
i need to set it up so that when a value from a checkbox is clicked, the database will be search for records(or rows) containing the values and pull up the row as a result.
p.s sorry for the long post just wanted to make sure i got everything in so it's less confusing please help me out or let me know anything else i'd have to tell you so you can help me out
Database
table name: DVD's
columns: D_id|Name |Type |Rating
Row 1: 1 |super bad|Movie|R
HTML
<form action="searchresults.php" method="post">
<input type="checkbox" name="Type[]" value="series" />Series
<input type="checkbox" name="Type[]" value="movie" />Movie
<input type="checkbox" name="Rating[]" value="R" />R
<input type="checkbox" name="Rating[]" value="PG 13" />PG 13
<input type="submit" value="Submit" />
</form>
PHP
<?php
$con=mysql_connect("localhost","username","password");
mysql_select_db("database", $con);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$Type = array("Series", "movie");
$result = mysql_query("SELECT * FROM DVD's");
?>
this is where im stuck or confused or just lack experience to figure it out, i tired different methods to finish off that php code with no luck but what i want to happen is the ability to use the checkbox options to find all movies that match your choices. i kno im doing something wrong just cant figure it out, i even tried the mysql_fetch_array() but i get back error message saying it's not a valid MYSQL result. can anybody please help me(if you need a better idea of what i want to do, it would be just like the search page on animenewsnetwork website for their search by genre option using checkbox to find the list of anime based on your choices.
i need to set it up so that when a value from a checkbox is clicked, the database will be search for records(or rows) containing the values and pull up the row as a result.
p.s sorry for the long post just wanted to make sure i got everything in so it's less confusing please help me out or let me know anything else i'd have to tell you so you can help me out