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

Last change on this file since 8793 was 8793, checked in by Daniela Dorner, 17 years ago
*** empty log message ***
File size: 5.3 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");
114printf("<tr><td valign='top'>\n");
115printf("<a href='http://db.astro.uni-wuerzburg.de'>home</a>\n");
116printf("</td><td align='center'>");
117if (!empty($prevseq))
118 printf("%d &nbsp;", $prevseq);
119if ($numseq>1)
120 printf("<input type='submit' value='<< Prev Plot' name='prev'>\n");
121if (empty($from))
122 $from=34099;//21.8.2004
123
124$db_id = mysql_connect($host, $user, $pw);
125if ($db_id==FALSE)
126{
127 printf("mysql_connect returned the following error:<br>");
128 printf("%s<br>", mysql_error());
129 die("");
130}
131 mysql_select_db($db);
132
133$query="SELECT fSourceKEY, fSourceName FROM Source ORDER BY fSourceName";
134$result=mysql_query($query);
135if (!$result)
136 printf("-N/A-");
137printf("&nbsp;<select name='source' size='1' class='Width'>\n");
138if (empty($source) || $source==0)
139 printf("<option value='0' selected>--- ALL ---</option>\n");
140else
141 printf("<option value='0'>--- ALL ---</option>\n");
142while ($row = mysql_fetch_row($result))
143{
144 if (!empty($source) && $source==$row[0])
145 printf("<option value='%s' selected>%s</option>\n", $row[0], $row[1]);
146 else
147 printf("<option value='%s'>%s</option>\n", $row[0], $row[1]);
148}
149printf("</select>\n");
150mysql_free_result($result);
151mysql_close($db_id);
152
153printf("from <input type='text' name='from' size='6' maxlength='8' value='%s'>\n", $from);
154printf(" to <input type='text' name='to' size='6' maxlength='8' value='%s'>\n", $to);
155PrintType2PullDown($type2);
156printf("<input type='text' name='tabnum' size='2' maxlenght='2' value='%s'>\n", $tabnum);
157printf("<input type='hidden' name='prevseq' size='2' maxlenght='2' value='%s'>\n", $prevseq);
158printf("<input type='hidden' name='nextseq' size='2' maxlenght='2' value='%s'>\n", $nextseq);
159if ($numseq>1)
160 printf("<input type='submit' value='Next Plot >>' name='next'>\n");
161else
162 printf("<input type='submit' value='Plot' name='next'>\n");
163if (!empty($nextseq))
164 printf("&nbsp;%d ", $nextseq);
165if ($numseq>0)
166{
167 printf("&nbsp; [ %d sequence", $numseq);
168 if ($numseq>1)
169 printf("s");
170 print(" ] \n");
171}
172printf("</td><td align='right'>\n");
173printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"showplots-seq.php\"'>\n");
174printf("</td>\n</tr>\n<tr>\n<td align='center' colspan='3'>\n");
175if (!empty($seq))
176 printf("%s <img src='%s'>", $plot, $plot);
177else
178 printf("Choose a source and/or a range of sequences or just click 'Plot' for going through all sequences.");
179printf("</td>\n</tr>\n</table>\n");
180printf("</form>\n");
181printf("</body>\n");
182printf("</html>\n");
183
184ini_set("display_errors", "Off");
185
186?>
Note: See TracBrowser for help on using the repository browser.