Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Hasil Kueri PHP/MySQL

coba yang seperti ini

// note we need to order by maincategory for this to work
//
$query = "SELECT DISTINCT a.categoryname AS maincategory, b.categoryname AS   
smallcategory FROM wscategories a, wssubcategories b WHERE a.SECTION = 'girls' AND  
b.parentcategory = a.id
ORDER BY maincategory ASC,
smallcategory ASC
";
      $result = mysql_query($query) or die(mysql_error());


      // keep track of previous maincategory
      $previous_maincategory = NULL;

      while ($row = mysql_fetch_assoc($result))
      {

        // if maincategory has changed from previouscategory then display it
        if ($previous_maincategory != $row['maincategory']) {
            echo $row['maincategory'];
        }

        echo "<br/>";
        echo $row['smallcategory'];
        echo "<br/>";

        // record what the previous category was
        $previous_maincategory = $row['maincategory'];
      }


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Mesin Pilihan MySQL – MyISAM atau InnoDB

  2. PHP MySQL Query paling populer dalam 24 jam terakhir

  3. Kesalahan Penyisipan PDO saat dijalankan

  4. Mengonversi kueri SQL kompleks ke SQLAlchemy

  5. Dua tabel - cara menghapus baris jika ID tidak dirujuk di kedua tabel