source: trunk/Mars/datacenter/db/showplots-seq.php@ 13408

Last change on this file since 13408 was 9466, checked in by aparavac, 15 years ago
*** empty log message ***
File size: 5.4 KB
Line 
1<?php
2
3ini_set("display_errors", "On");
4
5include("plotinclude.php");
6include("db.php");
7
8printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
9printf("<html>\n<head>\n");
10printf("<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>\n");
11printf("<title>show plots</title>\n");
12printf("<link rel='stylesheet' type='text/css' href='lamouette.css'>\n");
13printf("</head>\n");
14printf("<body>\n");
15
16//init
17$source="";
18if (!empty($_GET["source"]))
19 $source=$_GET["source"];
20$from="";
21if (!empty($_GET["from"]))
22 $from=$_GET["from"];
23$to="";
24if (!empty($_GET["to"]))
25 $to=$_GET["to"];
26$tabnum=1;
27if (!empty($_GET["tabnum"]))
28 $tabnum=$_GET["tabnum"];
29$type2="calib";
30if (!empty($_GET["type2"]))
31 $type2=$_GET["type2"];
32$plot="";
33$nextseq=0;
34$prevseq=0;
35$seq=0;
36if (!empty($_GET["prevseq"]) && !empty($_GET["prev"]))
37 $seq=$_GET["prevseq"];
38if (!empty($_GET["nextseq"]) && !empty($_GET["next"]))
39 $seq=$_GET["nextseq"];
40$next=0;
41$prev=0;
42$numseq=0;
43//$sequences=array(0,10,20);
44//$sequences=array();
45
46
47if (!empty($from) || !empty($to))
48{
49 //get sequences from db
50 $query="SELECT fSequenceFirst FROM Sequences ";
51 if (!empty($from) && !empty($to))
52 $query.="WHERE fSequenceFirst BETWEEN " . $from . " AND " . $to;
53 else
54 {
55 if (!empty($from))
56 $query.="WHERE fSequenceFirst > " . $from;
57 if (!empty($to))
58 $query.="WHERE fSequenceFirst < " . $to;
59 }
60 // WHERE has to be there as $from is given by default
61 if (!empty($source))
62 $query.=" AND fSourceKEY=" . $source;
63
64 //connection to database
65 $db_id = mysql_pconnect($host, $user, $pw);
66 if ($db_id==FALSE)
67 {
68 printf("mysql_connect returned the following error: %s\n", mysql_error());
69 die("");
70 }
71 mysql_select_db($db);
72
73 $result=mysql_query($query, $db_id);
74 while ($row = mysql_fetch_row($result))
75 $sequences[] = $row[0];
76 mysql_free_result($result);
77
78 mysql_close($db_id);
79
80 if (isset($sequences))
81 {
82 //get next, current and previous sequence
83 foreach($sequences as $key => $sequ)
84 {
85 if ($seq==0)
86 $seq=$sequ;
87 if ($next==1)
88 {
89 $nextseq=$sequ;
90 if ($prevseq!=0)
91 break;
92 $next=0;
93 }
94 if ($sequ==$seq)
95 {
96 $next=1;
97 continue;
98 }
99 $prevseq=$sequ;
100 }
101 $numseq=count($sequences);
102 //in case a dataset consists of less than 3 sequences
103 if ($numseq==2)
104 $nextseq=$prevseq;
105 }
106}
107
108
109$type=gettypename($type2);
110$plot=getplotname($seq, $tabnum, $type, $type2);
111
112printf("<form action='showplots-seq.php' method='GET'>\n");
113printf("<table width='100%%' border='0'>\n<tr>\n");
114PrintHomeHelp();
115printf("<td align='center'>\n");
116if (!empty($prevseq))
117 printf("%d &nbsp;", $prevseq);
118if ($numseq>1)
119 printf("<input type='submit' value='<< Prev Plot' name='prev'>\n");
120if (empty($from))
121 $from=34099;//21.8.2004
122
123$db_id = mysql_connect($host, $user, $pw);
124if ($db_id==FALSE)
125{
126 printf("mysql_connect returned the following error:<br>");
127 printf("%s<br>", mysql_error());
128 die("");
129}
130 mysql_select_db($db);
131
132$query="SELECT fSourceKEY, fSourceName FROM Source ORDER BY fSourceName";
133$result=mysql_query($query);
134if (!$result)
135 printf("-N/A-");
136printf("&nbsp;<select name='source' size='1' class='Width'>\n");
137if (empty($source) || $source==0)
138 printf("<option value='0' selected>--- ALL ---</option>\n");
139else
140 printf("<option value='0'>--- ALL ---</option>\n");
141while ($row = mysql_fetch_row($result))
142{
143 if (!empty($source) && $source==$row[0])
144 printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
145 else
146 printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
147}
148printf("</select>\n");
149mysql_free_result($result);
150mysql_close($db_id);
151
152printf("from <input type='text' name='from' size='6' maxlength='8' value='%s'>\n", $from);
153printf(" to <input type='text' name='to' size='6' maxlength='8' value='%s'>\n", $to);
154PrintType2PullDown($type2);
155printf("<input type='text' name='tabnum' size='2' maxlenght='2' value='%s'>\n", $tabnum);
156printf("<input type='hidden' name='prevseq' size='2' maxlenght='2' value='%s'>\n", $prevseq);
157printf("<input type='hidden' name='nextseq' size='2' maxlenght='2' value='%s'>\n", $nextseq);
158if ($numseq>1)
159 printf("<input type='submit' value='Next Plot >>' name='next'>\n");
160else
161 printf("<input type='submit' value='Plot' name='next'>\n");
162if (!empty($nextseq))
163 printf("&nbsp;%d ", $nextseq);
164if ($numseq>0)
165{
166 printf("&nbsp; [ %d sequence", $numseq);
167 if ($numseq>1)
168 printf("s");
169 print(" ] \n");
170}
171printf("</td><td align='right'>\n");
172printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"showplots-seq.php\"'>\n");
173printf("</td>\n</tr>\n<tr>\n<td align='center' colspan='3'>\n");
174if (!empty($seq))
175{
176 printf("<div onmouseover=\"this.innerHTML='%s'\" onmouseout=\"this.innerHTML='%s'\"> %s </div>", getinfofromdb($seq), $plot, $plot);
177 printf("<img src='%s'>", $plot);
178}
179else
180 printf("Choose a source and/or a range of sequences or just click 'Plot' for going through all sequences.");
181printf("</td>\n</tr>\n</table>\n");
182printf("</form>\n");
183printf("</body>\n");
184printf("</html>\n");
185
186ini_set("display_errors", "Off");
187
188?>
Note: See TracBrowser for help on using the repository browser.