Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338011
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338171
Share on other sites

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  ;D

Link to comment
https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338195
Share on other sites

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..

Link to comment
https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338272
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/67369-how-would-i-do-this/#findComment-338374
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.