Annotation of db/prgsrc/new/common.php, revision 1.1

1.1     ! roma7       1: <?
        !             2: $limit=200;
        !             3: function print_question($row) {
        !             4:        $row['tFileName']=str_replace('.txt','',$row['tFileName']);
        !             5:        $row['t1FileName']=str_replace('.txt','',$row['t1FileName']);
        !             6:        foreach ($row as $k=>$v) {
        !             7:                $row[$k]=preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/znatoki/images/db/$1"><p>',$v);
        !             8:                $row[$k]=preg_replace('/^\|([^\n]*)/','<pre>$1</pre>',$row[$k]);
        !             9:                $row[$k]=preg_replace('/^\s+/ms','<br>&nbsp;&nbsp;&nbsp;&nbsp;',$row[$k]);
        !            10:        }
        !            11:        include "question_template.php";
        !            12: }
        !            13: 
        !            14: function print_questions_sql($sql,$search=false) {
        !            15:        $res=mysql_query($sql) or print mysql_error().$sql;
        !            16:        print_questions_res($res,$search);      
        !            17: }
        !            18: 
        !            19: function print_questions_res($res,$search=false) {
        !            20:        global $limit;
        !            21:        $kvo=mysql_num_rows($res);
        !            22:        if ($search) {
        !            23:                if ($kvo==$limit) {
        !            24:                        print "More than $limit results";
        !            25:                } else print "$kvo results";
        !            26:                while ($row=mysql_fetch_assoc($res)) {
        !            27:                        print_question($row);
        !            28:                }
        !            29:        }
        !            30: }
        !            31: 
        !            32: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>