comparison interface/check_sections.php @ 0:b12c99b7c3f0

commit for previous development
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 19 Jan 2015 17:13:49 +0100
parents
children ef6d0c6a13d7
comparison
equal deleted inserted replaced
-1:000000000000 0:b12c99b7c3f0
1 <?php
2 include_once('Lib_mb_utf8.php');
3 include_once('config.php');
4 include_once('edit_section_db.php');
5 set_time_limit(0);
6 ini_set('memory_limit', '-1');
7
8 $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password);
9 mysql_query("SET NAMES utf8");
10
11 if (!$link_mysql) {
12 die('Could not connect: ' . mysql_error());
13 }
14
15 $db_selected = mysql_select_db($mysql_database, $link_mysql);
16 if (!$db_selected) {
17 die ('Can\'t use foo : ' . mysql_error());
18 }
19
20 function checkSections($count){
21
22 /* $query="SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections.name, start_page, end_page, COUNT( * ) AS count
23 FROM sections
24 JOIN books ON sections.books_id = books.id
25 WHERE NOT EXISTS
26 (SELECT 1 FROM sections_versions WHERE books_id=sections.books_id)
27 GROUP BY books_id, start_page, end_page
28 HAVING COUNT( * ) >=".$count."
29 ORDER BY COUNT( * ) DESC ";*/
30 $query="(SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections.name, start_page, end_page, COUNT( * ) AS count
31 FROM sections
32 JOIN books ON sections.books_id = books.id
33 WHERE NOT EXISTS
34 (SELECT 1 FROM sections_versions WHERE books_id=sections.books_id)
35 GROUP BY books_id, start_page, end_page
36 HAVING COUNT( * ) >=".$count.")
37 UNION
38 (SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections_revisions.name, start_page, end_page, COUNT( * ) AS count
39 FROM sections_revisions
40 JOIN books ON sections_revisions.books_id = books.id
41 JOIN (
42 SELECT sections_versions.id
43 FROM sections_versions WHERE sections_versions.version=(SELECT MAX(version) FROM sections_versions)
44 GROUP BY books_id
45 ) AS t ON t.id=sections_revisions.versions_id
46 WHERE deleted=0
47 GROUP BY books_id, versions_id,start_page, end_page
48 HAVING COUNT( * ) >=".$count.")
49 ORDER BY count DESC ";
50 $result = mysql_query($query);
51 echo mysql_num_rows($result)." result(s)<br><br>";
52 echo "<table>";
53 echo "<tr>";
54 echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2<td class='period'>period<td class='sectionName'>section name<td class='sectionName'>page<td class='page'>count";
55 while ($row = mysql_fetch_assoc($result)) {
56 $str="<tr>";
57 $str.="<td>".$row['book_name'];
58 $str.="<td>".$row['level1'];
59 $str.="<td>".$row['level2'];
60 $str.="<td>".$row['period'];
61 $str.="<td><a href='tagging_text.php?id=".$row['id']."' target='_blank'>".$row['name']."</a>";
62 $str.="<td>p".$row['start_page']."-".$row['end_page'];
63 $str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=".$count."' target='_blank'>".$row['count']."</a>";
64 echo $str;
65 }
66 echo "</table>";
67 }
68
69 ?>
70
71 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
72 <html>
73 <head>
74 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
75 <link href="css/search.css" type="text/css" rel="stylesheet"/>
76 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
77 <!--<script src="js/check_sections.js" charset="utf-8"></script>!-->
78 </head>
79 <body>
80 <form action='check_sections.php' method='GET'>
81 find sections overlapping more than <input type="text" name="count"> other sections
82 <input type="submit" name="find" value="find">
83 </form>
84 <br>
85 <div id="search_result">
86 <?php
87 if(isset($_GET['find']) && $_GET['count']!='' && is_numeric($_GET['count'])){
88 checkSections($_GET['count']);
89 }
90 ?>
91 </div>
92 </body>
93 </html>
94