<?php // compute summary statistics require_once 'login.php'; include 'functions.php'; $conn = new mysqli($db_hostname, $db_username, $db_password, $db_database); if ($conn->connect_error) { trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); } if (isset($_GET['type'])) { switch ($_GET['type']) { case 'pert_collections': // count numbers for different pert_collections $query = "SELECT pert_collection, COUNT(*) FROM drugs_lincs GROUP BY pert_collection"; $pert_collections = query_mysql($query, $conn); $conn->close(); $pert_collection_count = array(); foreach ($pert_collections as $key => $line) { if (is_null($line['pert_collection'])) { $pert_collection_count['NA'] = (int) $line['COUNT(*)']; } else { $pert_collection_count[$line['pert_collection']] = (int) $line['COUNT(*)']; } } echo json_encode($pert_collection_count); break; case 'fda_collections': // number of FDA approved drugs in collections $query = "SELECT pert_collection, COUNT(*) FROM drugs_lincs INNER JOIN drugs_drugbank ON drugs_lincs.pubchem_cid=drugs_drugbank.pubchem_cid OR drugs_lincs.pert_iname=drugs_drugbank.name GROUP BY pert_collection"; $rs = query_mysql($query, $conn); $conn->close();
<?php require_once 'login.php'; $umls_id = $_GET['name']; // echo $umls_id; $conn = new mysqli($db_hostname, $db_username, $db_password, $db_database); if ($conn->connect_error) { trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); } $query = "SELECT * FROM side_effects WHERE umls_id = ?"; $stmt = $conn->prepare($query); if ($stmt === false) { trigger_error('Wrong SQL query: ' . $query . ' Error: ' . $conn->error, E_USER_ERROR); } $stmt->bind_param('s', $umls_id); $stmt->execute(); $rs = $stmt->get_result(); $rs_arr = $rs->fetch_all(MYSQLI_ASSOC); $rs->free(); $stmt->close(); $conn->close(); // echo "side effect: " . $rs_arr[0]['name'] . "</br>"; // echo "synonyms: " . $rs_arr[0]['synonyms'] . "</br>"; $url = 'http://sideeffects.embl.de/se/' . $umls_id; $html = file_get_contents($url); echo $html;