How to Display Custom Link on a Web Site

Hello,

I am looking for an easy solution to the following problem.  I have a list of several thousand custom hyperlinks.  I would like to display these, one at a time, on a web page that I will call the Landing Page.  My website is a basic site that was created in Front Page. The links can only be used once, so the first visitor to the Landing Page would see Link #1, then the second visitor would see Link #2, etc. The links are in a simple txt file with one link per line.  Is there some easy way to do this with HTML and/or Javascript?  I am not a programming expert, so please try to make this simple.  If this is not possible on a Front Page site, I have a second site that is based on Dot Net Nuke.  I could have my landing page on that site, but would need help figuring out how to display one link at a time.  

Thanks for your help!!
MrChip2PresidentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

manavsiCommented:
well, if u know, javascript then, have ur links in a javascript array... and display them...

But remember js is a client side and it cant guarantee you exact processing of the links. May be have a database and put ur links there, and have a counter to chk the current visitor number and display ur link appropriately.

HTH
Manavsi
0
ddayx10Commented:
I am interrested to see what others say about this question. My personal thinking is that JavaScript and HTML are not going to be adequate for this task.

The languages simply are not aware of what other users are doing with potential links on the site. The only reasonable solution I see is to use a database to store your links. When a user asks for a link you give him the next available link from the database and mark is as unusable for the future.

I realize this may be much more complex than you were anticipating for your situation. Let's see what others think...

dday
0
MrChip2PresidentAuthor Commented:
Hi Manavsi,

Thanks for replying so quickly.  I am a novice when it comes to Javascript.  I have no idea to implement what you are suggesting.  I found my ISP will let me add a MySQL database to my website.  If I were to put the links into a new database, how would I display one link at a time?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

MrChip2PresidentAuthor Commented:
Hi ddayx10,

I think you are on the right track.  I just got off the phone with my ISPs tech support.  We created a new MySQL database for my site.  He said that I need to use PhP to import my list of hyperlinks into the database.  Then he said I will need another PhP script to display them one at a time to unique visitors.  I have never used PhP.  Would you (or someone else) be able to help me with the scripting for this?

Thanks!
0
ddayx10Commented:
I'm sorry. I was just answering to the capabilities of the languages you mentioned wanting to use. I don't know anything about dotnetnuke, and I don't utilize mysql. I am a asp.net programmer with a mostly sql background.

To interface with a database you are going to need to use a server side language (ASP, PHP, Java, etc). How you will retrieve the data is going to be determined by that language. I was simply posting to the nature of what was possible with HTML/JS to let you know that what you were trying to do is not a simple 1,2,3 generic task.

The scope of what you are asking is simply too large (at least for me). You are going to need to research MySql a bit, and how to interact with it using DotNetNuke (if that is possible). So I'd say wait and see what others think, maybe they will have some clever suggestions, or once you've familiarized yourself with these subjects a bit you might post a question in those areas of the site.



0
MrChip2PresidentAuthor Commented:
Thanks ddayx10,

I may post a related question in a different site.  I will wait to see if someone can come up with an alternative.  It is funny that you say you are an asp.net programmer.  I may post a separate question a little later about .NET 1.1 vs. 2.0.  As an expert can you monitor my postings?  If so, you may be able to help with that one.
0
ddayx10Commented:
sure I'll keep my eyes open :)
0
manavsiCommented:
MrChip2, Well, i see u now have a MySQL DB in ur site.. then.. u can easily PHPMyAdmin to create a DB...

1) Login to ur PHPMyAdmin, (if you dont know.. then ask ur ISP for that tool from ur Domain Control Panel)
2) Create a DataBase like say: domainname
3) Create a Table inside it.. say: links and another table say: visitor
4) Add the following fields in table links:
    * SNO -> Integer (length say 5... u can add 99999 links in that... )
    * Link -> VarChar (500 characters length)
5) Add the following fields in table visitor
    * SNO -> Integer
    * Visitor -> Integer (say 5 in length increase it depending on the traffic)
5) Click on save...
6) Now use the following PHP code on a page say links.php to display custom page...

HTH
Manavsi
<?
 
$host  = "domain.com"; // ur domain goes here
$uname = "username"; // Ur MySQL UserName here...
$pass = "password"; // ur MySQL PAssword here...
 
$db = "database_name"; // ur db name goes here
$table_name_visit = "table_name"; // ur table name goes here
$table_name_link = "link_name"; // ur links table name here
 
mysql_connect($host,$uname,$pass) or die("Err. connecting to MySQL DB");
 
mysql_select_db($dbname);
 
$query = "SELECT * FROM $table_name_link";
 
$result = mysql_query($query);
 
$number_of_rows = mysql_num_rows($result) - 1;
 
mysql_free_result($result);
 
// Connection 2
 
mysql_select_db($dbname);
 
$query = "SELECT 'Link' FROM `$table_name_visit`";
 
$result = mysql_query($query);
 
$row = mysql_fetch_row($result)
 
echo "<a href=\"". "$row[number_of_rows - 1] . "\"">"; // Printing the link... :)
 
mysql_free_result($result);
 
 
mysql_close();
?>

Open in new window

0
manavsiCommented:
sorry there seems to be one small error in the syntax.. try this..
<?
 
$host  = "domain.com"; // ur domain goes here
$uname = "username"; // Ur MySQL UserName here...
$pass = "password"; // ur MySQL PAssword here...
 
$db = "database_name"; // ur db name goes here
$table_name_visit = "table_name"; // ur table name goes here
$table_name_link = "link_name"; // ur links table name here
 
mysql_connect($host,$uname,$pass) or die("Err. connecting to MySQL DB");
 
mysql_select_db($dbname);
 
$query = "SELECT * FROM $table_name_link";
 
$result = mysql_query($query);
 
$number_of_rows = mysql_num_rows($result) - 1;
 
mysql_free_result($result);
 
// Connection 2
 
mysql_select_db($dbname);
 
$query = "SELECT 'Link' FROM `$table_name_visit`";
 
$result = mysql_query($query);
 
$row = mysql_fetch_row($result)
 
echo "<a href=\"". $row[number_of_rows - 1] . "\"">"; // Printing the link... :)
 
mysql_free_result($result);
 
 
mysql_close();
?>

Open in new window

0
MrChip2PresidentAuthor Commented:
manavsi,

Thank you!  I am going to try your solution out either later tonight (it is 10:30 pm my time) or tomorrow,  Assuming all goes well I will accept your solution (and sing your praises)!  Check back with my post in about 12-14 hours.
0
manavsiCommented:
sure.. All the best... :)

Manavsi
0
MrChip2PresidentAuthor Commented:
Hi manavsi,

OK, I am learning how to use PHPMyAdmin (my ISP does not provide support on this).

Here is what I have done so far:

1. created database called "surveywise"
2. created a table called "ConnectPressLinks".  In this table have two fields.  The SNO which is an Integer field with a length of 5 and link which is varchar(500),  I imported 3,318 links into the link field and made this an index.  The SNO field is currently empty.  Do I need to enter anything into SNO?  Is this a counter field?  Please see attached screen shot for table settings.
3. created a second table called visitor and have two fields, SNO which is an int(5) and visitor which is also int(5).  There is no data in this table.  Do I need to enter data and/or set an index?  If yes, please describe what I need to do.

I attached some screen shots of the database.

manavsi, it would be amazing if we could get this working in the next few hours.  I am working with someone on the east coast who wants this resolved today.  THANKS!


phphelp1.doc
0
manavsiCommented:
well... SNO field is just optional. may be you can just set it away.. i mean we dont use it.. u can just delete... it... i'll be right here to help you do it...

Manavsi
0
MrChip2PresidentAuthor Commented:
manavsi,

I also have some questions about your code.

First, once the code is updated with the correct database name, etc., are you saying I just save it as a file called "links.php" and then copy it to the root drive of my website?  Or would I create a new page in FrontPage, name it links.php, remove all HTML code and paste in your code?  Sorry if this seems like a silly question, I have never used php.  

Second, let's assume my domain is called chip.com.  Would the address for this page simply be http://chip.com/links.php?

Third, I have some questions on your actual code (which I list in bold)


<?
 
$host  = "chip.com"; // ur domain goes here  should this be chip.com or http://chip.com?
$uname = "username"; // Ur MySQL UserName here... is this the admin name for the database or for my website itself?  I don't think I have a separate username/password for MySQL.
$pass = "password"; // ur MySQL password here...
 
$db = "surveywise"; // ur db name goes here is this all I type, the database name?
$table_name_visit = "visitor"; // ur table name goes here  is this the correct table name?
$table_name_link = "ConnectPressLinks"; // ur links table name here is this the correct table name?  is it OK to have upper and lower case here?
 
mysql_connect($host,$uname,$pass) or die("Err. connecting to MySQL DB");
 
mysql_select_db($dbname); should this be mysql_select_db($db)?  we define $db above but not $dbname
 
$query = "SELECT * FROM $table_name_link";
 
$result = mysql_query($query);
 
$number_of_rows = mysql_num_rows($result) - 1;
 
mysql_free_result($result);
 
// Connection 2
 
mysql_select_db($dbname);  should this be ($db)?
 
$query = "SELECT 'Link' FROM `$table_name_visit`";
 
$result = mysql_query($query);
 
$row = mysql_fetch_row($result)
 
echo "<a href=\"". $row[number_of_rows - 1] . "\"">"; // Printing the link... :)
 
mysql_free_result($result);
 
 
mysql_close();
?>

Next, the hyperlinks are currently plain text in the table.  In other words, the entry says http://chip.com/specific_url.  When displayed will the links be active or do I need to wrap the A HREF code around all the entries to make the links display like links?

Finally (for now), I assume this page will only display one hyperlink on a blank screen.  What if I wanted to display some static text above the link.  For instance, something that says: "Thank  you for your interest.  Please click on the link below to begin."  How would I do that?

Thanks again!  I am so excited about making this work!
0
manavsiCommented:
wow... can u wait a min... My bro has got me a good quick plan for you.. like to consider that... NO DATABASE AT ALL... Just by using the file... :)

Awaiting ur reply..
0
manavsiCommented:
well chk out this simple solution from my bro... who said wanted to help you...

Link: http://www.4shared.com/file/107094295/2667e453/simpleLinks.html

Awaiting ur reply.. Mean while i'll get back to you on DB soon...
Manavsi
0
MrChip2PresidentAuthor Commented:
manavsi,

your brother takes after you - your are both geniuses!

I simply uploaded the three files to the root directory of my website and it works!!!!

Now I have just one final question, how do I modify dynamic_links.php to be able to display static text like I listed above (Thanks for your interest...)

Here is his code:

<?
// This file can do want u want without using any DB... :)

$visitorFile = "visitor.txt";
// Opening the visitor file to get the visitor number
$count = fopen($visitorFile, 'r');
$countNo = fgets($count);
fclose($count);
// closing the file

// Re-opening the file to update it..
$count = fopen($visitorFile, 'w') or die("can't open file");
fwrite($count, $countNo + 1);
fclose($count);
// Closing the file

// Opening the links file to get the appropriate link... :)
$myFile = "links.txt";
$handle = fopen($myFile, 'r');
$i = 0;
while (!feof($handle) && $i < $countNo)
{
$data = fgets($handle); // fetching the link...
$i++;
//echo $data;
//echo "<br>";
}
fclose($handle);
// Closing the links file

// Printing the link... :)
echo "<a href=http://".$data.">$data</a>";

?>

0
manavsiCommented:
yep.. here u have it... :)

HTH
Manavsi
<?
// This file can do want u want without using any DB... :)
 
$visitorFile = "visitor.txt";
// Opening the visitor file to get the visitor number
$count = fopen($visitorFile, 'r');
$countNo = fgets($count);
fclose($count); 
// closing the file
 
// Re-opening the file to update it.. 
$count = fopen($visitorFile, 'w') or die("can't open file");
fwrite($count, $countNo + 1);
fclose($count);
// Closing the file
 
// Opening the links file to get the appropriate link... :)
$myFile = "links.txt";
$handle = fopen($myFile, 'r');
$i = 0;
while (!feof($handle) && $i < $countNo)
{
$data = fgets($handle); // fetching the link...
$i++;
//echo $data;
//echo "<br>";
}
fclose($handle); 
// Closing the links file
 
// Printing the link... :)
echo "<b>Thank  you for your interest.  Please click on the link below to begin.</b><br>";
echo "<a href=http://".$data.">$data</a>";
 
?>

Open in new window

0
manavsiCommented:
note that the links.txt contains links in the format..
google.com
yahoo.com
and so on... note there is no http:// included... so only the code has http:// hardcoded in the code... if ur links.txt contains http:// then delete it from the code... else use the following line instead of above
<?
 
// Find this line
echo "<a href=http://".$data.">$data</a>";
 
// Replace it with
echo "<a href=".$data.">$data</a>";
 
// If all ur links are realtive to say.. chip.com then use this line
echo "<a href=http://chip.com/".$data.">$data</a>";
 
// try with each combination of the code before you get what you really want.... :)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MrChip2PresidentAuthor Commented:
This has to be one of the most  helpful solutions I have ever received on this forum.  Thank you!  THANK YOU!  Your database idea was great and your brother's help was exactly what I needed.  How can I thank him?  If you guys were local I would buy you both some beers.  
0
manavsiCommented:
well we are happy that it helped you... anytime... :)

Manavsi
Ashwanth (My Bro)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.