I am having problems understanding how to pass information and receive it on another page. I am working on a series of drop down menus where one can search a record album by year, then label, then artist then album name. Here is what I have so far:
http://www.runreturn.com/winestore/ch06 ... e.6-8e.php
when you select a year, the labels producing records in that year appear and that works fine.
But when you submit on this page with the label you've selected, it shows you artists which produce anytime as long as it's on the label. I want it to, instead, show artists that are on the label selected who released an album during the year that was originally selected.
I am very new to PHP and am thankful for any help.
Here is the code for the page I am stuck on where it displays the artists:
Code: Select all
<?php
// Connect to the server
if (!($connection = @ mysql_connect($hostName, $username, $password)))
showerror();
if (!mysql_select_db($databaseName, $connection))
showerror();
// Show all wines in a region in a <table>
function displayArtistList($connection,
$query,
$labelName)
{
// Run the query on the server
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Find out how many rows are available
$rowsFound = @ mysql_num_rows($result);
// If the query has results ...
if ($rowsFound > 0)
{
// ... print out a header
print "Artists under the label $labelName in $yearName<br>". "<br>".
"<SELECT NAME=artists>";
// Fetch each of the query rows
$options="artists";
while ($row = @ mysql_fetch_array($result))
{
$id=$rowї"id"];
//adding $rowї] allows for the options to show up
$artists=$rowї"artist"];
//$options.="<OPTION VALUE="$result">".$label;
$options=$artists;
// Print one row of results
print "<OPTION>$options</OPTION>";
} // end while loop body
} // end if $rowsFound body
print "</SELECT>" ."<br>" ."<br>" ;
// Report how many rows were found
print "\n" . "\n" ."{$rowsFound} artists found matching your criteria<br>";
} // end of function
// Connect to the MySQL server
if (!($connection = @ mysql_connect($hostName, $username, $password)))
die("Could not connect");
// Secure the user parameter $yearName
$labelName = mysqlclean($_GET, "label", 30, $connection);
// Secure the user parameter $yearName
$yearName = mysqlclean($_GET, "yearName", 30, $connection);
if (!mysql_select_db($databaseName, $connection))
showerror();
// Start a query ...
$query = "SELECT DISTINCT artist
FROM brazil
WHERE label = "{$labelName}"";
// ... then, if the user has specified a year, add the yearName
// as an AND clause ...
if (isset($yearName) && $yearName != "All")
$query .= " AND year = "{$yearName}"";
if (isset($labelName) && $labelName != "All")
$query .= " AND label = "{$labelName}"";
// ... and then complete the query.
$query .= " ORDER BY artist";
// run the query and show the results
displayArtistList($connection, $query, $labelName) . "\n" ."\n";
?>