Hello everyone, this is my first post here so I will try to make it as clear as possible.
Firstly i have a database with a single table named "albums" with the following fields:
Then i have two php pages
Search.php :
and Result.php :
This is as far as i have gotten with this, but i keep getting errors.
Please if someone can help I would be very thankful.
Firstly i have a database with a single table named "albums" with the following fields:
Code:
albumid int(11) genreid varchar(30) albumtitle varchar(30) albumauthor varchar(30 numberofsongs int(11 price int(11)
Search.php :
Code:
<html>
<center>
</br></br></br></br>
<img src="guitarlogo.jpg" alt="Music Database"/>
<form method="GET" action="Result.php">
<h2><b>Search Music Database:</b></h2>
<input type="text" name="mts" />
<input type="submit" name="submit" value="Search" />
</form>
<?php
$connection = mysql_connect("localhost","root","");
$fields = mysql_list_fields("ea09039", "albums", $connection);
$columns = mysql_num_fields($fields);
echo "<form action=Result.php method=POST>";
echo "<select name=Field>";
for ($i = 0; $i < $columns; $i++) {
echo "<option value=$i>";
echo mysql_field_name($fields, $i);
}
echo "</select></form>";
?>
</center>
</html>
Code:
<?php
include("db.php");
$mts=$_GET["mts"];
$Field=$_GET["Field"];
$query="select * from albums where '$Field' like '%$mts%'";
$res2=mysql_query($query);
while($row=mysql_fetch_row($res2))
{
echo $row[2];
echo " has author ";
echo $row[3];
echo " and costs ";
echo $row[5];
echo " Euro.";
echo " And is from the genre ";
echo $row[1];
echo "<br/>";
}
?>
Please if someone can help I would be very thankful.
Comment