query($sqlgroupname); if($resgroupname->num_rows){ $row = $resgroupname->fetch_array(); $group_name = $row["group_name"]; // get name if ($grp_id == 181) { // Outbreak channel requires union query to obtain biorxiv and medrxiv papers //$sqlbiorxiv = "SELECT * FROM test.biorxiv_index a, test.biorxiv_group_data_test b, test.biorxiv_abs c WHERE a.article_doi = b.group_data_doi AND b.group_data_doi = c.abs_doi AND b.group_names_id = $grp_id AND a.article_url = 1"; $sqlmedrxiv = "SELECT * FROM test.medrxiv_biorxiv_collections a, test.medrxiv_abs c WHERE a.article_doi = c.abs_doi AND a.article_url = 1 order by a.id desc limit 50"; $sqlbiorxiv = "SELECT * FROM test.medrxiv_biorxiv_collections a, test.biorxiv_abs c WHERE a.article_doi = c.abs_doi AND a.article_url = 1 order by a.id desc limit 50"; $resbiorxiv = $mysqli->query($sqlbiorxiv); $resmedrxiv = $mysqli->query($sqlmedrxiv); while($row = $resmedrxiv->fetch_array()){ getdata($row, "medrxiv"); } while($row = $resbiorxiv->fetch_array()){ getdata($row, "biorxiv"); } usort($arr, "cmp"); } // can add JSON feed for other channels } function getdata($row, $site = null){ global $mysqli, $arr; $obj = new stdClass(); $authors = array(); //$type = $row['article_type']; //if ($type == "PUBLISHAHEADOFPRINT"){$site = "medrxiv";} $obj->rel_title = $row['article_title']; $this_doi = $row['article_doi']; $obj->rel_doi = $this_doi; $this_mss = str_replace("10.1101/","",$this_doi); if($site == "biorxiv") { $obj->rel_link = "http://biorxiv.org/cgi/content/short/$this_mss"; $sqlauthors = "SELECT * FROM test.biorxiv_author_all WHERE author_doi = '$this_doi'"; } else if ($site == "medrxiv") { $obj->rel_link = "http://medrxiv.org/cgi/content/short/$this_mss"; $sqlauthors = "SELECT * FROM test.medrxiv_author_all WHERE author_doi = '$this_doi'"; } $obj->rel_abs = $row['abs_text']; $resauthors = $mysqli->query($sqlauthors); $this_num_authors = $resauthors->num_rows; $obj->rel_num_authors = $this_num_authors; for ($i = 0; $i < $this_num_authors; $i++) { $authrow = $resauthors->fetch_array(); $authors[$i]['author_name'] = $authrow['author_name']; $authors[$i]['author_inst'] = $authrow['author_inst']; } $obj->rel_authors = $authors; $obj->rel_date = $row['article_date']; $obj->rel_site = $site; $arr[] = $obj; } function cmp($a, $b) { return strcmp($b->rel_date, $a->rel_date); } // free the memory associated with results if (isset($res1)) { $res1->free(); } if (isset($res2)) { $res2->free(); } if (isset($res3)) { $res3->free(); } if (isset($res4)) { $res4->free(); } // close connection include "../close_symposia_new_all.php"; $jcb = ""; if(isset($_GET['jsoncallback'])) { $jcb = $_GET["jsoncallback"]; } print $jcb . '{"gname":"' . $group_name . '","grp_id":"' . $grp_id . '","rels":'.json_encode($arr).'}'; ?>