Filter Studies

"Descriptive Only", "review" => "Literature Review", "non" => "Non Experimental", "quasi" => "Quasi-Experimental", "random" => "Random Assignment" ); $host = "housinged.db.10785476.hostedresource.com"; $user = "housinged"; $password = "O6pmlv!!O6pmlv"; $db = "housinged"; $cxn = mysqli_connect($host,$user,$password,$db); if (!$cxn){ echo "Database error: ".mysqli_connect_error(); die(); } $query = "SELECT DISTINCT year FROM studies ORDER BY year"; $result = mysqli_query($cxn,$query); if (!$result){ echo "Error getting unique years: ".mysqli_error($cxn); die(); } $years = ''; while($row = mysqli_fetch_row($result)){ $years = $years.''; } $query = "SELECT first, last FROM authors GROUP BY firstlast ORDER BY last"; $result = mysqli_query($cxn,$query); if (!$result){ echo "Error getting unique authors: ".mysqli_error($cxn); die(); } $authors = ''; while($row = mysqli_fetch_row($result)){ $authors = $authors.''; } $query = "SELECT DISTINCT type FROM studies"; $result = mysqli_query($cxn,$query); if (!$result){ echo "Error getting unique studies: ".mysqli_error($cxn); die(); } $types = ''; while($row = mysqli_fetch_row($result)){ $types = $types.''; } echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; # Get number of studies $query = "SELECT count(studyID) FROM studies"; $result = mysqli_query($cxn,$query); if (!$result){ echo "Error getting studyID count: ".mysqli_error($cxn); die(); } $row = mysqli_fetch_row($result); $numStudies = $row[0]; echo '
'; for ($i=1;$i<=$numStudies;$i++){ # Studies data $query = "SELECT * FROM studies WHERE studyID = ".$i; $result = mysqli_query($cxn,$query); if (!$result){ echo "Error getting study information: ".mysqli_error($cxn); die(); } $row = mysqli_fetch_row($result); if ($row[4] == 'pdf'){ $text = 'Full Article (PDF)'; } else{ $text = 'Abstract'; } # Authors data - Number of authors $query = "SELECT count(authorNum) FROM authors WHERE studyID = ".$i; $author_result = mysqli_query($cxn,$query); if (!$author_result){ echo "Error getting authors: ".mysqli_error($cxn); die(); } $num_row = mysqli_fetch_row($author_result); $numAuthors = $num_row[0]; # Start outputting Divs echo '
'; echo '

'.$row[1].'

'; echo '
'; echo ''.$row[2].''; echo ''.$keys[$row[3]].''; echo ''.$text.''; echo '
'; echo '
By '; for ($j=1;$j<=$numAuthors;$j++){ $query = "SELECT * FROM authors WHERE studyID = ".$i." AND authorNum = ".$j; $authors_result = mysqli_query($cxn,$query); if (!$author_result){ echo "Error getting individual authors: ".mysqli_error($cxn); die(); } $authorRow = mysqli_fetch_row($authors_result); if (!$authorRow[3]){ $insert = ' '; } else { $insert = ' '.$authorRow[3].'. '; } if ($j == 1){ echo ''.$authorRow[2].$insert.$authorRow[4].''; if ($numAuthors > 2){ echo ''; } else if ($numAuthors == 2){ echo ' and '; } } else{ echo ''.$authorRow[2].$insert.$authorRow[4].''; if ($numAuthors > ($j + 1)){ echo ''; } else if ($numAuthors == ($j + 1)){ echo ', and '; } } } echo '
'; echo '
'; } echo '
'; $query = "SELECT max(year) FROM studies"; $result = mysqli_query($cxn,$query); if (!$result){ echo "Error getting unique years: ".mysqli_error($cxn); die(); } $yearsTo = ''; $row = mysqli_fetch_row($result); echo ''; ?>