PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Hint: use Ctrl+Enter for SQL autocomplete <?php include_once ('db_func.x.php'); DBopen(); $sql = "SELECT * FROM aktuality ORDER BY datum DESC LIMIT 3"; $res = mysqli_query($sql); $cnt = mysqli_num_rows($res); for ($i=0; $i<$cnt; $i++){ $text = mysqli_Result($res, $i, 'text'); echo '<b class="newsnadpis">'.mysqli_Result($res, $i, "nazev").' </b>'; echo '<span class="date">('.mysqli_Result($res, $i, "datum").')</span><br>'; if (strlen($text) > 95){ echo '<a class="CBOX newslink" href="/aktualita.php?id='.mysqli_Result($res, $i, 'id').'">'; //msg id too big, create short message $msgshort = substr($text, 0, 95); $msgLastSp = strrpos($msgshort, " "); $msgshort = substr($msgshort, 0, $msgLastSp) . "... "; echo $msgshort; echo '</a>'; } else{ echo $text; } echo '<hr class="newshr">'; } ?>
Copy Clear
Copy Format Clear
<?php include_once 'db_func.x.php'; DBopen(); $sql = "SELECT * FROM aktuality ORDER BY datum DESC LIMIT 3"; $res = mysqli_query($sql); $cnt = mysqli_num_rows($res); for ($i=0; $i<$cnt; $i++){ $text = mysqli_Result($res, $i, 'text'); echo '<b class="newsnadpis">'.mysqli_Result($res, $i, "nazev").' </b>'; echo '<span class="date">('.mysqli_Result($res, $i, "datum").')</span><br>'; if (strlen($text) > 95){ echo '<a class="CBOX newslink" href="/aktualita.php?id='.mysqli_Result($res, $i, 'id').'">'; //msg id too big, create short message $msgshort = substr($text, 0, 95); $msgLastSp = strrpos($msgshort, " "); $msgshort = substr($msgshort, 0, $msgLastSp) . "... "; echo $msgshort; echo '</a>'; } else{ echo $text; } echo '<hr class="newshr">'; } ?>
Show:  
Copy Clear