Skip to content

Instantly share code, notes, and snippets.

@sriannamalai
Created September 18, 2013 11:29
Show Gist options
  • Save sriannamalai/6607860 to your computer and use it in GitHub Desktop.
Save sriannamalai/6607860 to your computer and use it in GitHub Desktop.
Code to calculate the Virality of Social Networks.
<?php
$social = "TWITTER";
$result1 = mysql_query("SELECT * FROM table3") or die("Cannot get the results!");
$visits = mysql_num_rows($result1);
$result2 = mysql_query("SELECT * FROM table3 WHERE SOCIAL_SITE='".$social."'") or die("Cannot get the results!");
$clicks = mysql_num_rows($result2);
$virality = $clicks / $visits * 100;
echo $social.": Clicks ".$clicks." of visited ".$visits." has the Virality of <b>".$virality."%</b>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment