function studio_relevance($user_id, $user_genre) {
global $cxn; //MySQL connection
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
function studio_relevance($user_id, $user_genre) {
global $cxn; //MySQL connection
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Personalized, Weighted Recommendationsweighted recommendations - Rank All Content Withall content with PHP
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Personalized, Weighted Recommendations - Rank All Content With PHP
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Personalized, weighted recommendations - Rank all content with PHP
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Personalized, weighted recommendationsWeighted Recommendations - Rank all content withAll Content With PHP
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
}
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Personalized, weighted recommendations - Rank all content with PHP
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
}
else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Personalized, Weighted Recommendations - Rank All Content With PHP
function studio_relevance($user_id, $user_genre) {
global $cxn;
$query = "SELECT * FROM studio WHERE project_status='active'";
$result = mysqli_query($cxn, $query) or die($query.': '.mysqli_error($cxn));
$data = array();
while ($studio = mysqli_fetch_object($result)) {
//Find similarities in social connections and band
$query_b = "SELECT * FROM band WHERE studio_id=".$studio->studio_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$the_band = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$the_band[] = $people['user_id'];
}
$studio_band_count = count($the_band);
$query = "SELECT * FROM idols WHERE friend_id=".$user_id;
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$idol = array();
while ($people = mysqli_fetch_array($result_b, MYSQLI_ASSOC)) {
$idol[] = $people['artist_id'];
}
$same_band = array_intersect($the_band, $idol);
$same_band_count = count($same_band);
########
$similar_band = $same_band_count / $studio_band_count;
########
//Find the most recent activity
$query_b = "SELECT * FROM studio_feed WHERE studio_id=".$studio->studio_id." ORDER BY feed_id DESC LIMIT 1";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$tab = mysqli_fetch_object($result_b);
$time_diff = strtotime('now') - strtotime($tab->timestamp);
$hours = $time_diff / 3600;
########
$last_activity = pow(($hours+2), 1.8);
########
//Compare genres
$genre_weight = 1;
if ($studio->songGenre == $user_genre) {
$genre_weight = 3;
} else {
$query_b = "SELECT * FROM genres";
$result_b = mysqli_query($cxn, $query_b) or die($query_b.': '.mysqli_error($cxn));
$genres = array();
$user_genre_cat = 0;
while ($genre = mysqli_fetch_object($result_b)) {
$genres[$genre->genre_cat][] = $genre->genre_id;
if ($genre->genre_id == $user_genre) {
$user_genre_cat = $genre->genre_cat;
}
}
if (in_array($studio->songGenre, $genres[$celeb_cat])) {
$genre_weight = 2;
}
}
//Find final result
//$final = $similar_band + $last_activity + $genre_weight;
//$hours / pow(($similar_band+2), $genre_weight);
}
return $data;
}
Loading
lang-php