nemec Posted November 7, 2006 Report Share Posted November 7, 2006 <?php // function shows one texts from base function show_one_raksti($rak) { global $connection, $show, $config_format, $user_ip; if (!is_numeric($rak)) { return false; } $get_rezult = mysql_fetch_array(mysql_query("select id, head, text_small, text_main, UNIX_TIMESTAMP(created) as date, coments from it_raksti WHERE id='".$rak."' LIMIT 1")); if(!$get_rezult) { return false; } /////////////////////////////////////////// if (!empty($_POST['submit_comm']) && !empty($_POST['teksts_comm']) && !empty($_POST['name_comm'])) { if (strlen($_POST['name_comm']) < 15) { mysql_query("INSERT INTO it_raksti_comments ( id_it_raksti, ip,name,text_comment) VALUES ('".$rak."','".$user_ip."','".mysql_real_escape_string($_POST['name_comm'])."','".mysql_real_escape_string($_POST['teksts_comm'])."')"); } } ?> <div class="main_tekts"> <h2><?php echo $get_rezult['head'];?> </h2> <?php echo $get_rezult['text_small'];?> <?php echo $get_rezult['text_main'];?> </div> <div class="tekts_time"> <?php echo date($config_format['date_format'], $get_rezult['date']);?>, <?php echo date($config_format['time_format'], $get_rezult['date']);?> </div> <div class="tekts_comment_all"> <?php $get_rezult = mysql_query("select id, ip, name, text_comment, UNIX_TIMESTAMP(added) as date FROM it_raksti_comments WHERE id_it_raksti='".$rak."' ORDER by added ASC"); $a = 0; $mai = 0; while ($rezul = mysql_fetch_array($get_rezult)) { $mai = $mai == 0 ? 1 : 0; ?> <div class="tekts_comment"<?php //echo ($mai ? '#fff8dd' : '#ffffff');?>> <div class="comment_head"> <span class="comment_head_date"> <?php echo date($config_format['date_format'], $rezul['date']);?>, <?php echo date($config_format['time_format'], $rezul['date']);?> </span> <span class="comment_head_name"> <?php echo addslashes($rezul['name']);?> </span> <!--<div class="clearer"> </div>--> </div> <div class="comment_main"><?php echo addslashes($rezul['text_comment']);?></div> </div> <?php } ?> <div class="add_comment"> <form name="comment" action="?show=<?php echo $show;?>&rak=<?php echo $rak;?>" method="post"> <table> <tr> <td>vārds:</td><td><input class="add_comment_tekst" type="text" name="name_comm" /></td></tr> <tr> <td>teksts:</td><td><textarea class="add_comment_tekst" rows="4" cols="50" name="teksts_comm"></textarea></td></tr> <tr> <td colspan="2"><input class="poga_comm" type="submit" name="submit_comm" value="pievienot" /></td></tr> </table> </form> </div> </div> <?Php //var_dump ($get_rezult); } // function shows all texts in database function show_all_raksti($max = 5) { global $connection, $show, $config_format; ?> <h2>piezīmes</h2> <?php $get_rezult = mysql_query("select id, head, text_small, UNIX_TIMESTAMP(created) as date, coments from it_raksti ORDER by created DESC"); $a = 0; while ($rezul = mysql_fetch_array($get_rezult)) { $izvada_rezult [$a] = $rezul; $a++; } unset ($get_rezult, $rezul); $max = $max <= $a ? $max : $a; $start = 0; for ($q = 0; $q < $max; $q++) { $array_izvadam = $izvada_rezult[$q]; ?> <div class="intro_tekts"> <h3><?php echo $array_izvadam['head']; ?></h3> <?php echo $array_izvadam['text_small']; ?> <a href="?show=<?php echo $show;?>&rak=<?php echo $array_izvadam['id'];?>">vairāk</a> </div> <?php } ///// //$max++; ?> <div class="other_links"> <?php for ($q = $max; $q < $a; $q++) { $array_izvadam = $izvada_rezult[$q]; ?> <span class="rakstu_link"> <a href="?show=<?php echo $show;?>&rak=<?php echo $array_izvadam['id'];?>"><?php echo $array_izvadam['head'];?></a> (<?php echo date($config_format['date_format'], $array_izvadam['date']);?>, <?php echo date($config_format['time_format'], $array_izvadam['date']);?>)</a> </span><br /> <?php } ?> </div> <?php } //////////////////////////////////////////////////////////////////////// if (isset($_GET['rak'])) { show_one_raksti($_GET['rak']); } else { show_all_raksti(); } ?> mans blogs vienaa failaaa. ko diez te veel daliit pa failiem? tik daudz cilveeks vaaraas, jau sen taadus piecus vareeja uztaisiit pa sho laiku Link to comment Share on other sites More sharing options...
Recommended Posts