mattm1712 Posted September 20, 2010 Share Posted September 20, 2010 <html> <?php $id = $_GET['id']; $dbusername="web148-matt"; $dbpassword="matt"; $dbdatabase="web148-matt"; mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($dbdatabase) or die( "Unable to select database"); mysql_query("UPDATE count SET clicks=clicks+1 WHERE id='$id'"); $sql = mysql_query("SELECT link FROM count WHERE id='$id'"); $fetch = mysql_fetch_row($sql); $result = mysql_query("SELECT * FROM count"); while($row = mysql_fetch_array($result)) { echo "<a href=" .$row['link']. ">Link</a>"; } ?> <a href='http://www.google.com'>Google</a> <a href='/index.php?id=2'>link2</a> </html> Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/ Share on other sites More sharing options...
the182guy Posted September 20, 2010 Share Posted September 20, 2010 You can use MySQL substr but personally if I wanted to distinguish from internal and external URLs I would add a field to the table and call it 'external' and set it to a boolean. This way you could use WHERE external = 1 to find the external or WHERE internal = 0 to find the internal links. Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/#findComment-1113165 Share on other sites More sharing options...
Adam Posted September 20, 2010 Share Posted September 20, 2010 the182guy's method would also be a lot faster. Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/#findComment-1113166 Share on other sites More sharing options...
mattm1712 Posted September 20, 2010 Author Share Posted September 20, 2010 i am not sure how to use that tho i am new to php and know the basics getting more advanced i could do with and example to understand it Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/#findComment-1113168 Share on other sites More sharing options...
Adam Posted September 20, 2010 Share Posted September 20, 2010 Well, what is your current method of determining an internal link from an external one? Or at least, what is the theory behind it? Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/#findComment-1113183 Share on other sites More sharing options...
mattm1712 Posted September 20, 2010 Author Share Posted September 20, 2010 sorry i dont want to count the links i want to count how many times its been clicked Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/#findComment-1113185 Share on other sites More sharing options...
Adam Posted September 20, 2010 Share Posted September 20, 2010 Still, same question applies. If you want to know how to count 'external link' clicks, you need to specify how you determine an external link from an internal one within your DB table. Quote Link to comment https://forums.phpfreaks.com/topic/213876-i-can-count-internal-links-but-how-do-i-do-external-links-help-this-is-my-code/#findComment-1113186 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.