致命错误:未捕获错误:调用未定义函数mysql_result()

时间:2017-08-27 09:06:25

标签: php database pdo

我刚刚学会了php在页面上显示信息,我收到了一个错误,请帮帮我..谢谢

此filepolitik.php

<?php
  include 'koneksi.php';

  $tabel1 = 'isiberita';
  $tabel2 = 'kategori';
  $id=1;

  $hal = $_GET['hal']; //*Error : Notice: Undefined index: hal ???
  //validasi halaman
  if (!isset($_GET['hal'])) {
          $page = 1;
  } else {
    $page = $_GET['hal'];
  }
  //data tampil perhalaman
  $max_result = 2;

  $from = (($page * $max_result) - $max_result);

  //query tampil perhalaman
  $sql=$conn->query("SELECT * FROM  $tabel1,$tabel2 where $tabel1.id_kategori=$id and $tabel1.id_kategori=$tabel2.id_kategori
                    ORDER BY tanggal DESC LIMIT $from,$max_result");
while ($tampil = $sql->fetch(PDO::FETCH_ASSOC))
{

      $data = substr($tampil['isi'],0,200);
      echo "<div class='box'>";
      echo "<p align='justify'>";
      echo "<img class='gambar' src='$tampil[gambar]' width=150px height=150px align='left' />";
      echo "<font valign='top'>";
      echo "<strong>";
      echo $tampil['judul'];
      echo "</strong>";
      echo $data;

      echo "<a href='index.php?menu=detail_politik&id==$tampil[id_berita]'>  baca lengkap>>>></a>";
      echo "</font></p></div><br>";
}

//total
$total_result = mysql_result(mysql_query("SELECT count(*) as Num From $tabel1 where $tabel1.id_kategori=$id"),0); 
//Fatal error: Uncaught Error: Call to undefined function mysql_result() ??
$total_pages = ceil($total_result / $max_result);

echo "<center> piliih Halaman <br />";
//proses link
if ($hal > 1) {
  $prev = ($page - 1);
  echo "<a href=$_SERVER[PHP_SELF]?menu=politik&hal$prev>
        <-Sebelumnya </a>";
}

//link daftar urutan Halaman
for ($i=1; $i <= $total_pages; $i++) {
        if (($hal)==$i) {
          echo "$i";
        } else {
          echo "<a href=$_SERVER[PHP_SELF]?menu=politik&hal=$i>$i</a>";
        }
      }
        //link halaman selanjutnya
        if ($hal < $total_pages) {
          $next = ($page + 1);
          echo "<a href=$_SERVER[PHP_SELF]?menu=politik&hal=$next>Selanjutnya-></a>";
        }

      echo "</center>";

?>

此输出

enter image description here

0 个答案:

没有答案