调用PHP函数" mysql_query()"

时间:2014-04-21 10:47:04

标签: php mysql

我有这段代码:

<?php include('konek.php');

function cutStr($string, $word_limit = 30) {
$words = explode(" ",$string);
return implode(" ",array_splice($words,0,$word_limit)); }

$result=mysql_query("SELECT * FROM tblannouncement ORDER BY annTime DESC");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);

//PAGING CODE HERE

for ($i = $start; $i < $end; $i++) {
if ($i == $total_results) { break; }

while($row = mysql_fetch_array($result))
{
  if(isset($_REQUEST['read'])){
  echo $row['annContent'];
  echo '<br>';
  echo '...<br /><a href="?read">Read more</a>';
} else{
  echo cutStr($row['annContent'],20) . '. mysql_result($result, $i, 'annContent') .''...<br /><a href="?read">Read more</a>';
}
}

在代码中:

echo cutStr($row['annContent'],20) . '. mysql_result($result, $i, 'annContent') .''...<br /><a href="?read">Read more</a>';

我该如何正确地做到这一点?我的意思是我把cutStr放在哪里?在mysql_result里面?我在哪里适当地放一会儿?在寻呼的forloop里面?

0 个答案:

没有答案