チェンジセット 94: trunk/install/php/viewepg.php
- コミット日時:
- 2010/02/28 22:28:26 (15 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
trunk/install/php/viewepg.php
r91 r94 91 91 $maxdisplay = 8; 92 92 93 $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%' 94 "; 95 $rs = m_query($con, $query, "DBクエリに失敗しました"); 96 $maxrows = pg_num_rows($rs); 97 93 $query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'"; 94 //$rs = m_query($con, $query, "DBクエリに失敗しました"); 95 $rs = sql_query($con, $query, "DBクエリに失敗しました"); 96 $maxrows = $rs->fetchColumn(0); 98 97 if ($maxrows > $maxdisplay){ 99 98 $pages = ceil($maxrows / $maxdisplay) ; … … 138 137 $query = "SELECT stationid, stationname, stationrecch, ontvcode 139 138 FROM foltia_station 140 WHERE \"ontvcode\" ~~'%ontvjapan%'139 WHERE \"ontvcode\" LIKE '%ontvjapan%' 141 140 ORDER BY stationid ASC , stationrecch 142 OFFSET $offset LIMIT $maxdisplay 141 LIMIT ? OFFSET ? 143 142 "; 144 $slistrs = m_query($con, $query, "DBクエリに失敗しました"); 145 $stations = pg_num_rows($slistrs); 146 for ($i=0 ; $i < $stations ; $i++){ 147 $rowdata = pg_fetch_row($slistrs, $i); 148 $stationhash[$i] = $rowdata[3] ; 143 144 //$slistrs = m_query($con, $query, "DBクエリに失敗しました"); 145 $slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset)); 146 while ($rowdata = $slistrs->fetch()) { 147 $stationhash[] = $rowdata[3]; 148 $snames[] = $rowdata[1]; // headder 149 149 } 150 150 … … 158 158 SELECT ontvcode 159 159 FROM foltia_station 160 WHERE \"ontvcode\" ~~'%ontvjapan%'160 WHERE \"ontvcode\" LIKE '%ontvjapan%' 161 161 ORDER BY stationid ASC , stationrecch 162 OFFSET $offset LIMIT $maxdisplay162 LIMIT ? OFFSET ? 163 163 ) 164 AND startdatetime >= $start165 AND startdatetime < $epgend164 AND startdatetime >= ? 165 AND startdatetime < ? 166 166 ORDER BY foltia_epg.startdatetime ASC "; 167 167 168 $rs = m_query($con, $query, "DBクエリに失敗しました"); 168 //$rs = m_query($con, $query, "DBクエリに失敗しました"); 169 $rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend)); 169 170 170 171 //print "$query<br>\n"; 171 172 172 $ colmnums = pg_num_rows($rs);173 if ( $colmnums == 0){173 $rowdata = $rs->fetch(); 174 if (! $rowdata) { 174 175 //番組データがない 175 176 $colmnums = 2; 176 177 }else{ 177 for ($i=0 ; $i < $colmnums ; $i++){ 178 $rowdata = pg_fetch_row($rs, $i); 179 $timetablehash["$rowdata[0]"] = ($i + 1); 178 $colmnums = 0; 179 do { 180 $colmnums++; 181 $timetablehash[$rowdata[0]] = $colmnums; 180 182 // print "$rowdata[0]:$i+1 <br>\n"; 181 } 183 } while ($rowdata = $rs->fetch()); 182 184 } 183 185 //print "colmnums $colmnums <br>\n"; 184 186 185 187 //・局ごとに縦に配列入れていく 186 for ($j=0 ; $j < $stations ; $j++){ 187 $rowdata = pg_fetch_row($slistrs, $j); 188 $stationname = $rowdata[3]; 189 188 foreach ($stationhash as $stationname) { 190 189 $epgstart = $start ; 191 190 $epgend = calcendtime($start , (8*60)); … … 193 192 SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid , epgcategory 194 193 FROM foltia_epg 195 WHERE foltia_epg.ontvchannel = '$stationname'AND196 enddatetime > $epgstartAND197 startdatetime < $epgend194 WHERE foltia_epg.ontvchannel = ? AND 195 enddatetime > ? AND 196 startdatetime < ? 198 197 ORDER BY foltia_epg.startdatetime ASC 199 198 "; 200 $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 201 $maxrowsstation = pg_num_rows($statiodh); 202 203 //print "maxrowsstation $maxrowsstation stationname $stationname<br>\n"; 204 205 if ($maxrowsstation == 0) { 199 200 // $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 201 $statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend)); 202 $stationrowdata = $statiodh->fetch(); 203 if (! $stationrowdata) { 206 204 //print("番組データがありません<BR>"); 207 205 $item[0]["$stationname"] = ">番組データがありません"; 208 206 }else{ 209 210 for ($srow = 0; $srow < $maxrowsstation ; $srow++) { 211 212 $stationrowdata = pg_fetch_row($statiodh, $srow); 213 207 do { 214 208 $printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); 215 209 $tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); … … 235 229 }//if 236 230 237 }//for 231 } while ($stationrowdata = $statiodh->fetch()); 238 232 }//if 239 233 … … 291 285 292 286 //ヘッダ 293 for ($i=0;$i<$stations;$i++){ 294 $rowdata = pg_fetch_row($slistrs, $i); 295 print "<th>".htmlspecialchars($rowdata[1])."</th>" ; 287 foreach ($snames as $s) { 288 print "<th>".htmlspecialchars($s)."</th>" ; 296 289 } 297 290 //本体 298 291 for ($l = 0 ;$l < $colmnums; $l++){ 299 292 print "<tr>"; 300 for ($m = 0 ; $m < $stations ; $m++ ){ 301 $stationname = $stationhash[$m]; 293 foreach ($stationhash as $stationname) { 302 294 print_r($item[$l]["$stationname"]); 303 295 }