drlobo | voila la structure de la table
Code :
- CREATE TABLE `song` (
- `id` int(11) NOT NULL auto_increment,
- `band` varchar(128) NOT NULL default '',
- `album` varchar(128) default NULL,
- `title` varchar(128) NOT NULL default '',
- `lyrics` longtext NOT NULL,
- `user` varchar(128) default NULL,
- `date_creation` datetime NOT NULL default '0000-00-00 00:00:00',
- `date_modif` datetime default NULL,
- `checked` tinyint(4) NOT NULL default '0',
- UNIQUE KEY `id` (`id`),
- KEY `band` (`band`,`title`),
- FULLTEXT KEY `band_2` (`band`,`title`)
- ) TYPE=MyISAM;
|
et voila la requete (y a surement plein de truc a ameliorer de ce coté)
Code :
- $title=trim($title);
- $artist=trim($artist);
- switch($sart){
- case 1://perfect match
- $artist=" band like '$artist'";
- break;
- case 3: //all words
- $tableau=explode(" ",$artist);
- $artist="band like '%$tableau[0]%'";
- for ($i=1;$i<count($tableau);$i++){
- $artist.=" AND band like '%$tableau[$i]%'";
- }
- break;
- case 4: //any words
- $tableau=explode(" ",$artist);
- $artist="(band like '%$tableau[0]%'";
- for ($i=1;$i<count($tableau);$i++){
- $artist.=" OR band like '%$tableau[$i]%'";
- }
- $artist.=" )";
- break;
- default: //first word
- $artist=" band like '$artist%'";
- break;
- }
- switch($stit){
- case 1://perfect match
- $title="AND title like '$title'";
- break;
- case 3: //all words
- $tableau=explode(" ",$title);
- for ($i=0;$i<count($tableau);$i++){
- $title.=" AND title like '%$tableau[$i]%'";
- }
- break;
- case 4: //any words
- $tableau=explode(" ",$title);
- $title="(AND (title like '%$tableau[0]%'";
- for ($i=1;$i<count($tableau);$i++){
- $title.=" OR title like '%$tableau[$i]%'";
- }
- $title.=" )";
- break;
- default: //first word
- $title="AND title like '$title%'";
- break;
- }
- $sql ="select band,id,album,title,lyrics,date_creation from song2 where $artist $title LIMIT 0,21";
- $check =mysql_query($sql);
|
|