search.php

<?php
require ("db_mysql.php");

// Create connection to database:
//////////////////////////////////////////
// Initialise db class
$db = new DB_Sql;

// Set properties
$db->server = 'localhost'; // Enter your database server here, usually 'localhost'
$db->user = 'binet_lyrics'; // Enter your database user here
$db->password = 'pass'; // Enter your database password here
$dbname = 'binet_ldb'; // Enter your database name here

// Connect to database
$db->connect();

// Select database
$db->select_db($dbname);
//////////////////////////////////////////

// Set some inital variables
//////////////////////////////////////////
$perpage = 38;
$action = $_GET['action'];

// Get page
$page = $_GET['page'];

if (!is_numeric($page)) { $page = 1; }
//////////////////////////////////////////

// Select action
if ($action == 'search') {
// Perform search

$artist = $_GET['artist'];
$album = $_GET['album'];
$keywords = $_GET['keywords'];


// Check if there are any filter options
if (empty($artist) AND empty($album) AND empty($keywords)) {
die ("Please enter some keywords or an artist/album to search for.");
}

// Begin WHERE clause
$where = "WHERE 1=1";

if (!empty($keywords)) {
$keywords = str_replace("%", " ", $keywords);
$keywords = trim($keywords);
$keywords = str_replace(" ", "%", $keywords);
$keywords = str_replace("+", "%", $keywords);
$keywords = "%" . $keywords . "%";

$where .= " AND s.title LIKE '" . $db->sqlsafe($keywords) . "'";
}

if (!empty($artist)) {
$where .= " AND a.name = '" . $artist . "'";
}

if (!empty($album)) {
$where .= " AND a.title = '" . $album . "'";
}

// Get count how many lyrics there are
$count = $db->query_first ("SELECT COUNT(*) as songcount FROM songs AS s INNER JOIN artists AS a ON s.primaryartist = a.artistid LEFT JOIN albums AS al ON s.album = al.albumid " . $where);
$total = $count['songcount'];
$totalpages = ceil($total/$perpage);

// Check if current page is higher than total pages
if ($page > $totalpages) {
// Reset to last page
$page = $totalpages;
}

$songs = $db->sql_query ("SELECT s.songid, s.title, s.asin, s.ringtone, al.title AS albumtitle, al.asin, a.name FROM songs AS s INNER JOIN artists AS a ON s.primaryartist = a.artistid LEFT JOIN albums AS al ON s.album = al.albumid " . $where . " ORDER BY a.name ASC LIMIT " . (($page * $perpage)-$perpage) . ", " . $perpage);

Devam ediyor....

Lyrics.php

<?php
require ("db_mysql.php");

// Create connection to database:
//////////////////////////////////////////
// Initialise db class
$db = new DB_Sql;

// Set properties
$db->server = 'localhost'; // Enter your database server here, usually 'localhost'
$db->user = 'binet_lyrics'; // Enter your database user here
$db->password = 'pass'; // Enter your database password here
$dbname = 'binet_ldb'; // Enter your database name here

// Connect to database
$db->connect();

// Select database
$db->select_db($dbname);
//////////////////////////////////////////

// Set some inital variables
//////////////////////////////////////////
$perpage = 38;
$action = $_GET['action'];

// Get page
$page = $_GET['page'];

if (!is_numeric($page)) { $page = 1; }
//////////////////////////////////////////

// select action
if ($action == 'songs') {
// Check if there are any filter options
if (empty($_GET['artist']) && empty($_GET['album']) && empty($_GET['letter'])) {
// No filter options, set to letter 'a'
$letter = '09';
} else {
// Get filter options
$letter = strtolower($_GET['letter']);
$artist = $_GET['artist'];
$album = $_GET['album'];

// Validate letter option
if (!preg_match('([a-z])', $letter)) {
// Invalid letter, set to letter 'a'
$letter = '09';
}
}

// Where clause:
$where = "WHERE s.letter = '" . $letter . "'";

if (!empty($artist)) {
$where .= " AND a.name = '" . $artist . "'";
}

if (!empty($album)) {
$where .= " AND a.title = '" . $album . "'";
}

// Get count how many lyrics there are
$count = $db->query_first ("SELECT COUNT(*) as songcount FROM songs AS s INNER JOIN artists AS a ON s.primaryartist = a.artistid LEFT JOIN albums AS al ON s.album = al.albumid " . $where);
$total = $count['songcount'];
$totalpages = ceil($total/$perpage);

Devam ediyor...

db_mysql.php

<?php
error_reporting(7);
// db class for mysql
// this class is used in all scripts
// do NOT fiddle unless you know what you are doing

class DB_Sql {
var $database = "";

var $link_id = 0;
var $query_id = 0;
var $record = array();

var $errdesc = "";
var $errno = 0;
var $reporterror = 1;

var $server = "";
var $user = "";
var $password = "";

var $appname = "B-Inet Lyrics";
var $appshortname = "B-Inet Lyrics";

function connect() {
global $usepconnect;
// connect to db server

if ( 0 == $this->link_id ) {
if ($this->password=="") {
if ($usepconnect==1) {
$this->link_id=mysql_pconnect($this->server,$this->user);
} else {
$this->link_id=mysql_connect($this->server,$this->user);
}
Devam ediyor...

adsearch.php

<?php
require ("db_mysql.php");

// Create connection to database:
//////////////////////////////////////////
// Initialise db class
$db = new DB_Sql;

// Set properties
$db->server = 'localhost'; // Enter your database server here, usually 'localhost'
$db->user = 'binet_lyrics'; // Enter your database user here
$db->password = 'pass'; // Enter your database password here
$dbname = 'binet_ldb'; // Enter your database name here

// Connect to database
$db->connect();

// Select database
$db->select_db($dbname);
//////////////////////////////////////////

// Set some inital variables
//////////////////////////////////////////
$perpage = 38;
$action = $_GET['action'];

// Get page
$page = $_GET['page'];

if (!is_numeric($page)) { $page = 1; }
//////////////////////////////////////////

// Select action
if ($action == 'search') {
// Perform search

$artist = $_GET['artist'];
$album = $_GET['album'];
$keywords = $_GET['keywords'];


// Check if there are any filter options
if (empty($artist) AND empty($album) AND empty($keywords)) {
die ("Please enter some keywords or an artist/album to search for.");
}

// Begin WHERE clause
$where = "WHERE 1=1";

if (!empty($keywords)) {
$keywords = str_replace("%", " ", $keywords);
$keywords = trim($keywords);
$keywords = str_replace(" ", "%", $keywords);
$keywords = str_replace("+", "%", $keywords);
$keywords = "%" . $keywords . "%";

$where .= " AND s.title LIKE '" . $db->sqlsafe($keywords) . "'";
}

if (!empty($artist)) {
$where .= " AND a.name = '" . $artist . "'";
}

if (!empty($album)) {
$where .= " AND a.title = '" . $album . "'";
}

// Get count how many lyrics there are
$count = $db->query_first ("SELECT COUNT(*) as songcount FROM songs AS s INNER JOIN artists AS a ON s.primaryartist = a.artistid LEFT JOIN albums AS al ON s.album = al.albumid " . $where);
$total = $count['songcount'];
$totalpages = ceil($total/$perpage);

// Check if current page is higher than total pages
if ($page > $totalpages) {
// Reset to last page
$page = $totalpages;
}

$songs = $db->sql_query ("SELECT s.songid, s.title, s.asin, s.ringtone, al.title AS albumtitle, al.asin, a.name FROM songs AS s INNER JOIN artists AS a ON s.primaryartist = a.artistid LEFT JOIN albums AS al ON s.album = al.albumid " . $where . " ORDER BY a.name ASC LIMIT " . (($page * $perpage)-$perpage) . ", " . $perpage);



// Show search results:

// START YOUR PAGE HERE (HTML)
?>

Devam ediyor