\n"; exit(0); } if ($q_error1 || $q_error2 || $q_error3 ) { echo "

Please correct the highlighted entries and try again!\n"; exit(0); } $query=setup_query(); $result=mysql_query($query); $num=0; $num=mysql_numrows($result); mysql_close(); echo "

\n\n\n
Records found: $num     Subspecies searched: ".$_POST['genome']."
\n"; if ($num == 0) { echo "\n"; exit(0); } $page_size=1000; $pages =(int) ceil($num/$page_size); $page =$_POST['page']; $displayed=$page_size; if ($page==-1) $page=$pages-1; $firstr=$page*$page_size+1; $lastr=$firstr+$page_size-1; if ($lastr > $num) $lastr=$num; echo "\n"; record_navigation($page, $pages, $page_size, $firstr, $lastr); echo ""; record_navigation($page, $pages, $page_size, $firstr, $lastr); echo "
"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; $i=$page*$page_size; while (($i < $num) && ($i < ($page+1)*$page_size)) { $chromosome =mysql_result($result,$i,"Chromosome"); $position =mysql_result($result,$i,"Position"); $reference =mysql_result($result,$i,"Reference"); $allele =mysql_result($result,$i,"Allele"); $region =mysql_result($result,$i,"Region"); $locus =mysql_result($result,$i,"Locus"); $effect =mysql_result($result,$i,"Effect"); $changed_to =mysql_result($result,$i,"Changed_to"); $changed_from=mysql_result($result,$i,"Changed_from"); $formatted_pos=number_format($position); if ($i % 2) $color="#ffffff"; else $color="#e9e9e9"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ( $locus != "" ) { echo "\n"; } else echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; $i++; } echo "
 Rec. #  Chrom. #  Position  Reference    Allele    Region  Locus  Protein Change 
 Effect    To    From 
".($i+1)." $chromosome   $formatted_pos   $reference $allele   $region      $locus    $locus     $effect     $changed_to     $changed_from  
"; function record_navigation($page, $pages, $page_size, $firstr, $lastr) { echo "Page ".($page+1)." of ".$pages.""; echo "Records $firstr - $lastr"; echo ""; echo "\n"; if ($pages>1) { if ($page!=0 ) echo " \n"; if ($page!=$pages-1) echo " \n"; echo "    "; } if ($page>0) { echo " \n"; if ($page>9) echo " \n"; } if ($page<$pages-1) { if ($page < ($pages-10)) echo " \n"; echo " \n"; } echo ""; } function setup_query() { $query="select * from ".$_POST['genome']; $add_and=0; $add_or=0; $add_where=1; if ( $_POST['chrom'][0] == "" ) { $parent_started=0; for ($i=1; $i<13; $i++) { if ( $_POST['chrom'][$i] != "" ) { if ( $add_where == 1) { $query.=" where"; $add_where=0; } if ( $parent_started == 0) { $query.=" ("; $parent_started=1;} if ( $add_or == 1) { $query.=" or"; } $query.=" chromosome=".$_POST['chrom'][$i]; $add_or=1; $add_and=1; } } if ( $parent_started == 1 ) { $query.=" )";} $add_or=0; } if ( $add_where == 1) { $query.=" where"; $add_where=0; } if ( $add_and == 1) { $query.=" and "; } $query.=" Position>".$_POST['position_low']." and". " Position<".$_POST['position_high']; $add_and=1; if ( $_POST['region'] != "any" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1 ) { $query.=" and"; } $query.=" Region='".$_POST['region']."'"; $add_and=1; } if ( $_POST['reference'] != "any" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" Reference='".$_POST['reference']."'"; $add_and=1; } if ( $_POST['allele'] != "any" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" Allele='".$_POST['allele']."'"; $add_and=1; } if ( $_POST['changed_from'] != "any" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" changed_from='".$_POST['changed_from']."'"; $add_and=1; } if ( $_POST['changed_to'] != "any" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" changed_to='".$_POST['changed_to']."'"; $add_and=1; } if ( $_POST['locus'] != "" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" locus='LOC_OS".$_POST['locus']."'"; $add_and=1; } if ( $_POST['effect'] == "NULL" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" Effect IS NULL"; $add_and=1; } else if ( $_POST['effect'] != "any" ) { if ( $add_where==1 ) {$query.=" where"; $add_where=0;} if ( $add_and == 1) { $query.=" and"; } $query.=" Effect='".$_POST['effect']."'"; $add_and=1; } //echo "
SQL query:
$query

\n"; return $query; } function db_login() { $user="root"; $password="pw4mysql"; $database="oryza_sativa"; mysql_connect(localhost,$user,$password); @mysql_select_db($database) or die( "Unable to select database"); } ?>