acidglitter Posted August 30, 2007 Share Posted August 30, 2007 What I have: I have articles and tutorials on my site and they're both in a table called tutorials What I want: to have a section at the bottom of every article or tutorial saying "related links" and have links to articles and tutorials that are about similar topics I have a faint idea how to do this. I'm thinking I might make a separate table that has the id# of a specific article/tutorial and then have a new row for each keyword. Then on the related links section it would put all of that article/tutorials keywords into an array and then do a search for articles/tutorials that have the same keywords. Would that work? and how could I do that? Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/ Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 i dont understand that much but i guess you have to have a crossing table or an ID of each field that will determine the subcategory of each category you want. To accomplish this you have to do some joining procedure Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338007 Share on other sites More sharing options...
Ken2k7 Posted August 30, 2007 Share Posted August 30, 2007 Just create a new column in that table and sort out the tutorials by type or whatever. Then call upon all the tutorials of that type, given a limit and display them. Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338008 Share on other sites More sharing options...
acidglitter Posted August 30, 2007 Author Share Posted August 30, 2007 Just create a new column in that table and sort out the tutorials by type or whatever. Then call upon all the tutorials of that type, given a limit and display them. All of them will have more than one keyword though so it seems like it would be easier to make a separate table. Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338011 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 if your talking about one t0 many relationship then you really have to make a new table not new field Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338019 Share on other sites More sharing options...
acidglitter Posted August 31, 2007 Author Share Posted August 31, 2007 Okay this is what I've put together today. Its only a testing page to get the code right.. $id=$_GET['id']; $searchquery="SELECT * FROM tutorialtags WHERE "; $needand=0; $fsearchh=mysql_query("SELECT * FROM tutorialtags WHERE tutid='$id'"); while($fsearch=mysql_fetch_array($fsearchh)){ if($needand>0){ $searchquery.= " AND "; } $tuttag=$fsearch['tag']; echo "$tuttag<br>"; $searchquery.= "tag='$tuttag'"; $needand++; } echo "<hr>"; echo "$searchquery<hr>"; $searchh=mysql_query($searchquery); while($search=mysql_fetch_array($searchh)){ echo "{$search['tutid']} - {$search['tag']}<br />"; } If I put 11 as the id, the page looks like eyes eyeshadow --------------------------------------------------------- SELECT * FROM tutorialtags WHERE tag='eyes' AND tag='eyeshadow' --------------------------------------------------------- How should I change the code so it would put links to tutorials with eyes and eyeshadow first, then links to tutorials with only eyeshadow in the tag second? Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338171 Share on other sites More sharing options...
teng84 Posted August 31, 2007 Share Posted August 31, 2007 in your case you need to create a new query for that specific link you want but i would rather do it this way note asterisk is bad example select * from category considering your category is listed like ME MY SELf each category will have a link for each subcategory if i click one of those category itwll navigate to each sub sample ID for ME =1 select * from subcat where id=1 sample results: YOU THEm THERE now those subcat should have spicific link and will only return one result for each subcategory oops sorry bad english Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338195 Share on other sites More sharing options...
acidglitter Posted August 31, 2007 Author Share Posted August 31, 2007 That would work except I don't want the links to go to subcatagories, I want the links to go to actual tutorials that are in the same catagory. I'm thinking I might just do like 2 or 3 different queries, where the first would search for tutorials with almost all of the same tags, and the 2nd query would search for tutorials with only a couple of the same tags.. Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338272 Share on other sites More sharing options...
acidglitter Posted August 31, 2007 Author Share Posted August 31, 2007 Okay I've made two tables. tutorialtags: id tag tutorialtagss: id tagid tag tutid What I want to happen is you'll look at a tutorial with the id 11. So a query will get all of the tags from tutorialtagss that have the tutid of 11. Then I want to only see the tutid's of tutorials that have at least 3 of the same tags as tutorial 11. Hopefully that makes more sense. Is this even possible? I've worn myself out trying to figure out a way to do this. Quote Link to comment https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338374 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.