forcer Posted November 6, 2008 Share Posted November 6, 2008 I have a list of links in an array, and a small script that will show a link from the array at random. is there anything i can add to it that will record the number of times each link is clicked. maybe just stored in a text file or something? here is the source if it helps: <?php $links = array('<a href="link1">link1</a>', '<a href="link2">link2</a>','<a href="link3">link3</a>','<a href="link4">link4</a>'); $items = $links; $item = rand(0, sizeof($items)-1); echo $items[$item]; ?> Link to comment https://forums.phpfreaks.com/topic/131630-link-click-tracking/ Share on other sites More sharing options...
revraz Posted November 6, 2008 Share Posted November 6, 2008 You can store it in a text file or a DB. Just write it each time it's clicked. Link to comment https://forums.phpfreaks.com/topic/131630-link-click-tracking/#findComment-683657 Share on other sites More sharing options...
Zhadus Posted November 6, 2008 Share Posted November 6, 2008 As revraz stated, a text file or database would be the best solution. I'd recommend the database as you're almost sure to have another use for one. In the meantime, I cleaned up your code which I think is easier to maintain: <?php $links = array('link1', 'link2', 'link3', 'link4'); $items = $links; $item = rand(0, sizeof($items)-1); $link = $items[$item]; echo '<a href="' . $link . '">' . $link . '</a>'; ?> Link to comment https://forums.phpfreaks.com/topic/131630-link-click-tracking/#findComment-683661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.