newbwoi Posted April 6, 2010 Share Posted April 6, 2010 Hi, I'm new to Mysql database and I'm in the process of creating a CMS using PHP and mysql. I came across this challenge when I decided to display the related contents of this video like for example youtube when you click on a particular video you get related videos on the site similar to that I want to display related video using similar tags. Or another popular example would be a blog article and it displays similar related article on the page. In my table it has the following fields Id, title, description, tags...... and all other information about each video including specific tags. The tags are determined by the title of the video EX: the title of the video is "Today is a holiday in Canada 05/04/2010" and then I used the php code strtolower to lower case the title and then I used explode(" ",$tags); to separate the title into each word and using a loop I inserted those separated words into the tag field of the table. So now the tags field contains "today is a holiday in canada 05/04/2010 ". Now that you know about my database and the table On the video display page, I want to show the related videos on the side. I tired the following but it does not adequate my goal. $sql6 = "SELECT * FROM $tbl_name WHERE tags LIKE '%$tags%' ORDER BY id DESC"; $result6=mysql_query($sql6); echo "<table border='1'>"; echo "<tr> <th>Video</th></tr>"; // keeps getting the next row until there are no more to get while($row5 = mysql_fetch_array( $result6 )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row5['title']; echo "</td></tr>"; } echo "</table>"; Please write up a mysql query to suit my needs and please give your feedback to improve the table/website or any other suggestion that may help me. Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.