Am un script de muzica,si pe index apar melodiile noi intr-un tabel,dar apar toate categoriile?
Cum pot face de ex. sa apara mai jos 10 melodii dintr-o anumita categ. 10 din alta?
Cine stie?Pot pune fisierul index.php aici :-? ma ajuta careva?
cine stie php cat de cat?
Moderators: Moderatori ajutatori, Moderatori
-
- Fost administrator
- Posts: 13712
- Joined: 09 Oct 2010, 12:39
- Detinator Steam: Da
- CS Status: In grajd!
- SteamID: kalulord
- Reputatie: Fost Administrator
Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra - Location: Romania, Ploiesti
- Has thanked: 328 times
- Been thanked: 646 times
- Contact:
Cam asa se face un select in sql.
Sau daca sunt 2 tabele diferite poti folosi left join.
Code: Select all
SELECT id,nume,melodie FROM categories WHERE catname = 'numecategorie' ORDER BY id LIMIT 10
Pune fisierul aici.SELECT
melodie.id
melodie.nume,
melodie.link,
categorie.id,
categorie.nume
FROM melodie
LEFT JOIN
castegorie
ON
melodie.id = categorie.id
WHERE categorie.nume = 'cenumevreitu'
Last edited by The Kalu on 31 Mar 2012, 20:29, edited 1 time in total.
- Kryme
- Membru, skill +4
- Posts: 1922
- Joined: 31 Dec 2008, 12:45
- Detinator Steam: Da
- SteamID: PM si il dau.
- Reputatie: Ban 1 luna
Ban 2 luni - Location: Zalău
- Has thanked: 132 times
- Been thanked: 69 times
Uite aici. http://www.girlshare.ro/3587527.9Terra. wrote:Cam asa se face un select in sql.Pune fisierul aici.Code: Select all
SELECT id,nume,melodie FROM categories WHERE catname = 'numecategorie' ORDER BY id LIMIT 10
-
- Fost administrator
- Posts: 13712
- Joined: 09 Oct 2010, 12:39
- Detinator Steam: Da
- CS Status: In grajd!
- SteamID: kalulord
- Reputatie: Fost Administrator
Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra - Location: Romania, Ploiesti
- Has thanked: 328 times
- Been thanked: 646 times
- Contact:
Sper ca ti-am fost de folos,daca nu te pricepi PM.
Code: Select all
<?php
include('config.php');
print 'Categorii muzica: <br />
<a href="?cat=Manele">Manele</a>
<a href="?cat=HipHop">Manele</a>
<a href="?cat=Rap">Manele</a>
<a href="?cat=House">Manele</a>
<a href="?cat=Jazz">Manele</a>
';
if(isset($_GET['cat'])){
$cat = $_GET['cat'];
switch($cat){
case 'Manele':
$manele= mysql_query("SELECT
`titlu`,`categorie`,`link`,`link2`,`download`,`data_ad`,`uploadat`,`hits`,`tags`,`linkpoza`,`descriere` FROM `melodie` WHERE `categorie` = 'Manele'");
while($row = mysql_fetch_array($manele)){
///Aici faci print la datele care ai nevoie.
}
break;
case 'HipHop':
$hiphop= mysql_query("SELECT
`titlu`,`categorie`,`link`,`link2`,`download`,`data_ad`,`uploadat`,`hits`,`tags`,`linkpoza`,`descriere` FROM `melodie` WHERE `categorie` = 'HipHop'");
while($row = mysql_fetch_array($hiphop)){
///Aici faci print la datele care ai nevoie.
}
break;
case 'Rap':
$rap= mysql_query("SELECT
`titlu`,`categorie`,`link`,`link2`,`download`,`data_ad`,`uploadat`,`hits`,`tags`,`linkpoza`,`descriere` FROM `melodie` WHERE `categorie` = 'Rap'");
while($row = mysql_fetch_array($rap)){
///Aici faci print la datele care ai nevoie.
}
break;
case 'House':
$house= mysql_query("SELECT
`titlu`,`categorie`,`link`,`link2`,`download`,`data_ad`,`uploadat`,`hits`,`tags`,`linkpoza`,`descriere` FROM `melodie` WHERE `categorie` = 'House'");
while($row = mysql_fetch_array($house)){
///Aici faci print la datele care ai nevoie.
}
break;
case 'Jazz':
$jazz= mysql_query("SELECT
`titlu`,`categorie`,`link`,`link2`,`download`,`data_ad`,`uploadat`,`hits`,`tags`,`linkpoza`,`descriere` FROM `melodie` WHERE `categorie` = 'Jazz'");
while($row = mysql_fetch_array($jazz)){
///Aici faci print la datele care ai nevoie.
}
break;
//Inchidem siwtch-ul
}
//Inchidem get-ul
}
?>
-
- Information
-
Who is online
Users browsing this forum: A k c 3 n 7, eternity, MDFK. eXtream, Mralexx1994 and 352 guests