Jump to content

i can count internal links but how do i do external links help? this is my code


Recommended Posts

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

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.

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.

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.