<link rel="stylesheet" type="text/css" href="style.css">
<h1>Search Results</h1>

<?//print_r(r_POST);
include "conninfo.php";
$search=$_POST["gen"];

if ($search!="") //not equal to nothing 
{
	echo "Results for <i>".$search."</i>:<br><br>";	
	
$query="SELECT * FROM songs WHERE genre like '$search'";
//echo $query;
$result=mysqli_query($link,$query) or die("didn't work");
$numrows=mysqli_num_rows($result); //how many rows are found

if ($numrows==0)
{
	echo "Sorry, nothing found.";	
}
else 
{
	echo "<table>";
            echo "<tr>";
                echo "<th>Song ID</th>";
                echo "<th>Song Name</th>";
                echo "<th>Artist</th>";
                echo "<th>Genre</th>";
				echo "<th>Length</th>";
				echo "<th>Release Date</th>";
				echo "<th>Star Rating</th>";
				echo "<th>YouTube Link</th>";
				
            echo "</tr>";
        while($row = mysqli_fetch_array($result)){
            echo "<tr>";
                echo "<td>" . $row['songid'] . "</td>";
                echo "<td>" . $row['songname'] . "</td>";
                echo "<td>" . $row['artist'] . "</td>";
                echo "<td>" . $row['genre'] . "</td>";
				echo "<td>" . $row['length'] . "</td>";
				echo "<td>" . $row['releasedate'] . "</td>";
				echo "<td>" . $row['starrating'] . "</td>";
				echo "<td>" . $row['youtube'] . "</td>";
				
            echo "</tr>";
        }
        echo "</table>";
        // Free result set
        mysqli_free_result($result);
	

	// while($r=mysqli_fetch_array($result)) //get row
	// {
		// echo $r["songname"].", ";
		// echo $r["artist"].", ";
		// echo $r["genre"].", ";
		// echo $r["length"].", ";
		// echo $r["releasedate"].", ";
		// echo $r["starrating"].", ";
		// echo $r["youtube"]."";?><br><br><?
	// }
	// echo "<br>$numrows results found <br><br>";
}
}
?> 
<a href ="search.php"><h2>Go back to the search page</h2></a>
<a href ="songs.php"><h2>Go back to the songs</h2></a>