PDA

View Full Version : Scanning Content and Creating Links


redsox9
02-28-2006, 05:48 AM
Okay, here's another challenge from the guy who keeps asking newbie PHP scripting questions... :D

I would like a PHP script that reads through the content of an web document and, when it finds partuicular keywords, automatically creates a link to another page using those keywords as the identifier. Specifically, I would like something that looks for a player's name, searches a database, and then creates a link to that player's page. It's not that I couldn't do that manually every time I write an article but, as each player's page requires a somewhat complex link, I'd like to make my life just that much easier.

I have a vague idea of how to perform this task but I'm looking for an assist from someone more savvy with PHP. I've done a couple of searches online to try and find a snippet but no luck thus far.

Chew on that one, my friends. :cool:

2notch
02-28-2006, 01:43 PM
To do it only once, lets start with:
-Is it a text file to be scanned or something else?
-Is this the link structure and does it remain constant (except for the "players_schilling.html" ?
http://www.fenwayfanatics.com/redsox/2006_team/players_schilling.html

Here's what has to be done:
Step 1 - build database with player's firstname, lastname , link_to_page, etc.
Step 2 - (in a loop) parse the file you've written and search for match in lastname, firstname. Return link_to_page, lastname, firstname to app and create link around match in original text file. (continue looping until EOF then exit)

If you have a lot of names to link in an article, there may be a lot of querying before it loads the page. So do it once, when you write the article.

Sound like what you need?

redsox9
02-28-2006, 03:41 PM
I have an idea... Let's change the name of this forum from bluehost to Ask 2notch Questions. :D

I had a feeling that was the solution but I had hoped that there was something "automated" to reduce the scope of my efforts. I already have in mind the script to do this and should be able to create something relatively simple to handle this. Thanks again for your help!

(Of course, if anyone else has a thought on this, I'd love to hear it!)

2notch
02-28-2006, 04:36 PM
I have an idea... Let's change the name of this forum from bluehost to Ask 2notch Questions. :D

aww man that's cold...:p

I had a feeling that was the solution but I had hoped that there was something "automated" to reduce the scope of my efforts. I already have in mind the script to do this and should be able to create something relatively simple to handle this. Thanks again for your help!

(Of course, if anyone else has a thought on this, I'd love to hear it!)

It can be automated. It can be done on the fly as the page loads. The first suggestion was to keep overhead down.

Post your code here and let's see what you've got so far...;)

redsox9
02-28-2006, 05:08 PM
aww man that's cold...:p

Oh, you can take it. ;)

In all seriousness, though, I've really enjoyed reading some of your posts in regard to web authoring and so forth. You obviously are very dedicated to the craft. In fact, I checked out the site in your signature and was very impressed with the graphics that you created.

It can be automated. It can be done on the fly as the page loads. The first suggestion was to keep overhead down.

Post your code here and let's see what you've got so far...;)

Yes, sorry, I did catch the original flavor of your post where you alluded to automating the process. I'm going to try both at some point (not right away) and if I run into problems I know EXACTLY where to go. :D

2notch
02-28-2006, 05:20 PM
Oh, you can take it. ;)

In all seriousness, though, I've really enjoyed reading some of your posts in regard to web authoring and so forth. You obviously are very dedicated to the craft. In fact, I checked out the site in your signature and was very impressed with the graphics that you created.

Yes, sorry, I did catch the original flavor of your post where you alluded to automating the process. I'm going to try both at some point (not right away) and if I run into problems I know EXACTLY where to go. :D

Thanks man, you're too kind. BTW that's a pretty nice site you have there. Did you do all the layout and code?

redsox9
02-28-2006, 05:35 PM
Thanks man, you're too kind. BTW that's a pretty nice site you have there. Did you do all the layout and code?

Yes that was all me last winter using NoteTab Light and PaintShop Pro v.6. I'm old school. :rolleyes:

Actually, I had thought about switching to PHP last year but decided that I didn't have the time to learn. This year, I still don't have the time but, come hell or high water, I'm going to make the switch! :D

ocmnet
03-06-2006, 03:32 PM
I plan on selling my solution when I get it wrapped right. How much is your time worth? I might sell you a cheap eval copy...

redsox9
03-06-2006, 04:53 PM
I plan on selling my solution when I get it wrapped right. How much is your time worth? I might sell you a cheap eval copy...

Yeah, it's not a big deal at the moment and, to be honest, I should be able to tailor a program that will suit my needs. Thanks for checking with me, though - it's quite possible that someone else may have interest.