dauzcode

mysql-num_row and field

Sep 20th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.70 KB | None | 0 0
  1. <html>
  2. <head><title>belajarPHP</title>
  3. </head>
  4. <body>
  5. <?php
  6.     $pemakai = "php";
  7.     $password = "007php";
  8.     $id_mysql = mysql_connect("localhost", $pemakai, $password);
  9.    
  10.      if (! $id_mysql)
  11.         die ("gagal melakukan koneksi silahkan di cek kembali pengaturan database");   
  12.        
  13.      if (! mysql_select_db("bukulmt", $id_mysql))
  14.         die ("database tidak bisa di pilih");
  15.      
  16.      $hasil = mysql_query("SELECT * FROM daftar", $id_mysql);
  17.      if(! $hasil)
  18.         die("permintaan gagal dilaksanakan");
  19.      
  20.      $jum_kolom = mysql_num_fields($hasil);
  21.      $jum_baris = mysql_num_rows($hasil);
  22.      print("Jumlah Kolom : $jum_kolom <BR>dan jumlah baris $jum_baris  <BR>\n");
  23.      mysql_close($id_mysql);
  24. ?>             
  25. </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment