129 | | |
---|
130 | | |
---|
131 | | $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%' ORDER BY stationid ASC , stationrecch OFFSET $offset LIMIT $maxdisplay |
---|
| 124 | //ココから新コード |
---|
| 125 | //・局リスト |
---|
| 126 | $query = "SELECT stationid, stationname, stationrecch, ontvcode |
---|
| 127 | FROM foltia_station |
---|
| 128 | WHERE \"ontvcode\" ~~ '%ontvjapan%' |
---|
| 129 | ORDER BY stationid ASC , stationrecch |
---|
| 130 | OFFSET $offset LIMIT $maxdisplay |
---|
| 131 | "; |
---|
| 132 | $slistrs = m_query($con, $query, "DBクエリに失敗しました"); |
---|
| 133 | $stations = pg_num_rows($slistrs); |
---|
| 134 | for ($i=0 ; $i < $stations ; $i++){ |
---|
| 135 | $rowdata = pg_fetch_row($slistrs, $i); |
---|
| 136 | $stationhash[$i] = $rowdata[3] ; |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | //・時間と全順番のハッシュ作る |
---|
| 140 | $epgstart = $start ; |
---|
| 141 | $epgend = calcendtime($start , (8*60)); |
---|
| 142 | |
---|
| 143 | $query = "SELECT DISTINCT startdatetime |
---|
| 144 | FROM foltia_epg |
---|
| 145 | WHERE foltia_epg.ontvchannel in ( |
---|
| 146 | SELECT ontvcode |
---|
| 147 | FROM foltia_station |
---|
| 148 | WHERE \"ontvcode\" ~~ '%ontvjapan%' |
---|
| 149 | ORDER BY stationid ASC , stationrecch |
---|
| 150 | OFFSET $offset LIMIT $maxdisplay |
---|
| 151 | ) |
---|
| 152 | AND startdatetime >= $start |
---|
| 153 | AND startdatetime < $epgend |
---|
| 154 | ORDER BY foltia_epg.startdatetime ASC "; |
---|
| 155 | |
---|
| 156 | $rs = m_query($con, $query, "DBクエリに失敗しました"); |
---|
| 157 | $colmnums = pg_num_rows($rs); |
---|
| 158 | if ($colmnums == 0){ |
---|
| 159 | //番組データがない |
---|
| 160 | $colmnums = 2; |
---|
| 161 | }else{ |
---|
| 162 | for ($i=0 ; $i < $colmnums ; $i++){ |
---|
| 163 | $rowdata = pg_fetch_row($rs, $i); |
---|
| 164 | $timetablehash["$rowdata[0]"] = $i; |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | //・局ごとに縦に配列入れていく |
---|
| 168 | for ($j=0 ; $j < $stations ; $j++){ |
---|
| 169 | $rowdata = pg_fetch_row($slistrs, $j); |
---|
| 170 | $stationname = $rowdata[3]; |
---|
| 171 | |
---|
| 172 | $epgstart = $start ; |
---|
| 173 | $epgend = calcendtime($start , (8*60)); |
---|
| 174 | $query = " |
---|
| 175 | SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid |
---|
| 176 | FROM foltia_epg |
---|
| 177 | WHERE foltia_epg.ontvchannel = '$stationname' AND |
---|
| 178 | enddatetime > $epgstart AND |
---|
| 179 | startdatetime < $epgend |
---|
| 180 | ORDER BY foltia_epg.startdatetime ASC |
---|
133 | | $rs = m_query($con, $query, "DBクエリに失敗しました"); |
---|
134 | | |
---|
135 | | //print "<!--$query -->"; |
---|
136 | | $viewstations = pg_num_rows($rs); |
---|
137 | | print "</p> |
---|
138 | | <table width=\"100%\" border=\"0\"> |
---|
139 | | <tbody> |
---|
140 | | <tr class=\"kyoku\"> |
---|
141 | | "; |
---|
142 | | for ($i=0 ; $i < $viewstations ; $i++){ |
---|
143 | | $rowdata = pg_fetch_row($rs, $i); |
---|
144 | | if ($rowdata[1] != ""){ |
---|
145 | | print " <th scope=\"col\">$rowdata[1]</th>\n"; |
---|
| 182 | $statiodh = m_query($con, $query, "DBクエリに失敗しました"); |
---|
| 183 | $maxrowsstation = pg_num_rows($statiodh); |
---|
| 184 | if ($maxrowsstation == 0) { |
---|
| 185 | //print("番組データがありません<BR>"); |
---|
| 186 | $item[0]["$stationname"] = "番組データがありません"; |
---|
| 187 | }else{ |
---|
| 188 | |
---|
| 189 | for ($srow = 0; $srow < $maxrowsstation ; $srow++) { |
---|
| 190 | |
---|
| 191 | $stationrowdata = pg_fetch_row($statiodh, $srow); |
---|
| 192 | |
---|
| 193 | $printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); |
---|
| 194 | $tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); |
---|
| 195 | $title = $stationrowdata[3]; |
---|
| 196 | $title = htmlspecialchars(z2h($title)); |
---|
| 197 | $desc = $stationrowdata[4]; |
---|
| 198 | $desc = htmlspecialchars(z2h($desc)); |
---|
| 199 | $height = htmlspecialchars($stationrowdata[2]) * 3; |
---|
| 200 | $epgid = htmlspecialchars($stationrowdata[7]); |
---|
| 201 | |
---|
| 202 | if (isset($timetablehash["$stationrowdata[0]"])){ |
---|
| 203 | $number = $timetablehash["$stationrowdata[0]"]; |
---|
| 204 | }else{ |
---|
| 205 | $number = 0; |
---|
| 206 | } |
---|
| 207 | $item["$number"]["$stationname"] = "$printstarttime <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc"; |
---|
| 208 | }//for |
---|
| 209 | }//if |
---|
| 210 | |
---|
| 211 | //・局ごとに間隔決定 |
---|
| 212 | //$item[$i][NHK] はヌルかどうか判定 |
---|
| 213 | $dataplace = 0 ; //初期化 |
---|
| 214 | $rowspan = 0; |
---|
| 215 | |
---|
| 216 | for ($i=1; $i <= $colmnums ; $i++){ |
---|
| 217 | if ($i === ($colmnums - 1)){//最終行 |
---|
| 218 | $rowspan = $i - $dataplace + 1; |
---|
| 219 | //そして自分自身にタグを |
---|
| 220 | if ($item[$i][$stationname] == ""){ |
---|
| 221 | $item[$i][$stationname] = ""; |
---|
| 222 | }else{ |
---|
| 223 | $item[$i][$stationname] = "<td>". $item[$i][$stationname] . "</td>"; |
---|
| 224 | $rowspan--; |
---|
| 225 | } |
---|
| 226 | //ROWSPAN |
---|
| 227 | if ($rowspan === 1 ){ |
---|
| 228 | $item[$dataplace][$stationname] = "<td>". $item[$dataplace][$stationname] . "</td>"; |
---|
| 229 | }else{ |
---|
| 230 | $item[$dataplace][$stationname] = "<td rowspan = $rowspan>". $item[$dataplace][$stationname] . "</td>"; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | }elseif ($item[$i][$stationname] == ""){ |
---|
| 234 | //ヌルなら |
---|
| 235 | $item[$i][$stationname] = $item[$i][$stationname] ; |
---|
| 236 | }else{ |
---|
| 237 | //なんか入ってるなら |
---|
| 238 | $rowspan = $i - $dataplace; |
---|
| 239 | if ($rowspan === 1 ){ |
---|
| 240 | $item[$dataplace][$stationname] = "<td>". $item[$dataplace][$stationname] . "</td>"; |
---|
| 241 | }else{ |
---|
| 242 | $item[$dataplace][$stationname] = "<td rowspan = $rowspan>". $item[$dataplace][$stationname] . "</td>"; |
---|
| 243 | } |
---|
| 244 | $dataplace = $i; |
---|
| 245 | |
---|
147 | | } |
---|
148 | | |
---|
149 | | print " </tr> |
---|
150 | | |
---|
151 | | <tr valign = top> |
---|
152 | | "; |
---|
153 | | for ($i=0 ; $i < $viewstations ; $i++){ |
---|
154 | | $rowdata = pg_fetch_row($rs, $i); |
---|
155 | | if ($rowdata[3] != ""){ |
---|
156 | | print "<td>"; |
---|
157 | | renderepgstation($con,$rowdata[3],$start); |
---|
158 | | print "</td>\n"; |
---|
| 247 | }//for |
---|
| 248 | }// end of for://・局ごとに縦に配列入れていく |
---|
| 249 | |
---|
| 250 | //・テーブルレンダリング |
---|
| 251 | print "<table>\n<tr>"; |
---|
| 252 | |
---|
| 253 | //ヘッダ |
---|
| 254 | for ($i=0;$i<$stations;$i++){ |
---|
| 255 | $rowdata = pg_fetch_row($slistrs, $i); |
---|
| 256 | print "<th>".htmlspecialchars($rowdata[1])."</th>" ; |
---|
| 257 | } |
---|
| 258 | //本体 |
---|
| 259 | for ($l = 0 ;$l < $colmnums; $l++){ |
---|
| 260 | print "<tr>"; |
---|
| 261 | for ($m = 0 ; $m < $stations ; $m++ ){ |
---|
| 262 | $stationname = $stationhash[$m]; |
---|
| 263 | print_r($item[$l]["$stationname"]); |
---|