I am trying to link one variable in the search results to its corresponding variable which is in the same row but on a different field result.
For Example
title || lyrics
father || am i so proud to be your son...
If I search for father, I get father in the search results.
I am trying to get the title "father" to be displayed as a link so that when it is clicked, the lyrics: "I am so proud to be your son" will be displayed on screen. It can either be a pop up window or a new screen.
I tried linking the title to the lyrics directly in the part of my script that prints the search results, it sort of works but it gives me a message: forbidden... You don't have permission to access.....[my server dir]..."the lyrics from the title displayed here"...on this server.
This is my script...
<?php>
//-query the database table
$song="SELECT title,writers.Author,bible.ref,lyrics FROM writers LEFT JOIN bible ON writers.SongNo = bible.SongNo WHERE (`title` LIKE '%" . $name . "%' OR `Author` LIKE '%" . $name . "%')";
//-run the query against the mysql query function
$result=mysql_query($song);
//-create while loop and loop through result set
$num_rows = mysql_num_rows($result);
echo "<hr>";
echo "<h4 align='right'> Search for '$name' found $num_rows\n Results...</h4>";
while($row=mysql_fetch_array($result)){
$Author =$row['Author'];
$lyrics=$row['lyrics'];
$title=$row['title'];
$SongNo=$row['SongNo'];
$ref=$row['ref'];
$rest = substr("$lyrics",0,180);
//-display the result of the array
if($num_rows==0){
echo "Sorry, search found zero results."; //if there are zero rows, then it will echo this out.
} else {
print '<p class="sansserif"><b>Song title : </b> <a href="'.$lyrics.'">'.$title.'</a><br />';
print "<b>Author</b>: $Author <br />" . "<b>Reference</b>: $ref <br />" . "<b>Lyrics</b>: $rest</p>";
}
}
}
else{
echo "<p><b>Please enter search term, we suggest the name of an author or a song title</p></b><hr/>";
}
}
}
?>