Forum Moderators: coopster
Here is form with options to choose from 2 tables in the database.
Works when I just have 1 option but when I combine the two - no output - HELP!
<form action="TCTest7.php" method="post">
<p>shopgirl
<input type="radio" value="Aerial" name="title" />
<br/>
2005
<input type="radio" value="The Devil Drive" name="title" />
</p>
<p>releaseyear
<input type="radio" value="2005" name="releaseyear" />
<br/>
<input type="submit" />
</p>
</form>
<?php
$link = mysql_connect("localhost","","");
mysql_select_db("createdb1", $link) or die("Unable to select database");
$selectSql = "SELECT * FROM music WHERE releaseyear = '".mysql_real_escape_string($_POST['releaseyear'])."'
AND title = '".mysql_real_escape_string($_POST['title'])."'";
echo $selectSql;
$result = mysql_query($selectSql, $link) or die(mysql_error());
mysql_close($link);
?>
You aren't actually going through the results and printing them out.
Try something like this:
<?php
$link = mysql_connect("localhost","","");
mysql_select_db("createdb1", $link) or die("Unable to select database");
#
$selectSql = "SELECT * FROM music WHERE releaseyear = '".mysql_real_escape_string($_POST['releaseyear'])."'
AND title = '".mysql_real_escape_string($_POST['title'])."'";
#
echo $selectSql;
$result = mysql_query($selectSql, $link) or die(mysql_error());
while($row = [url=http://www.php.net/mysql-fetch-assoc]mysql_fetch_assoc[/url]($result)) {
echo '<pre>';
[url=http://www.php.net/print-r]print_r[/url]($row);
echo '</pre>';
}
mysql_close($link);
?>
A more in-depth look here: [webmasterworld.com...]
Good luck! :)