Php/mysql korte hulp nodig

Gestart doorAdmir7 reacties49 weergaven

8 berichten · pagina 1 van 1

Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben nog steeds bezig met het uitbreiden van me script.
Ik heb al totale tracks/muziek eruit gehaalt dankzij erik & lennard.

Maar dit snap ik helemaal niet zo goed in me database heb ik deze tabel :
Afbeelding

en daarin zit nog een zn tabel: artiesten, als ik dat ga verkennen zie ik dit :
Afbeelding

die 1 en 2 dat zijn IDs, nou wil dat al die 1 IDs worden getelt en dan bij artiest met de ID 1 in komt. Vind het moeilijk uit te leggen. maar dit is dus artiest met ID 1 ;
http://straatpower.xtreemhost.com/index.php?pagina=rap&rap=1 en onder woonplaats moet komen de totale muziek wat er in de database zijn te vinden.

Het zijn er nu 17 en dat getal wil ik onder woonplaats zien te krijgen.

Kan iemand me helpen aub?cry
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$tracks = mysql_result(mysql_query("SELECT COUNT(1) FROM track WHERE artiesten=".$artiest[id].""), 0);


zoiets?
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sjoerd schreef:
$tracks = mysql_result(mysql_query("SELECT COUNT(1) FROM track WHERE artiesten=".$artiest[id].""), 0);
zoiets?

ik ga zo eens proberen? moet ik het in een echo zette?
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ja
maar je moet dat $artiest[id] wel aanpassen denk ik
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sjoerd schreef:
ja
maar je moet dat $artiest[id] wel aanpassen denk ik

Heb hem bijna, tekst staat er maar er staat 0 i.p.v 17
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dit is me script rap.php

Quote:
$_GET[rap] = mysql_real_escape_string($_GET[rap]);

$rap_select = mysql_query("

SELECT
id,
artiesten,
woonplaats
FROM
artiesten
WHERE
id = ".$_GET[rap]."
ORDER BY
artiesten ASC

") or die(mysql_error());

if(!mysql_num_rows($rap_select))
{

echo "Deze artiest bestaat niet.";

}
else
{

while($show2 = mysql_fetch_assoc($rap_select))
{

$show2[artiesten] = stripslashes($show2[artiesten]);
$show2[artiesten] = htmlentities($show2[artiesten]);
$show2[woonplaats] = stripslashes($show2[woonplaats]);
$show2[woonplaats] = htmlentities($show2[woonplaats]);
$tracks = mysql_result(mysql_query("SELECT COUNT(1) FROM track WHERE artiesten=".$artiest[id].""), 0);

echo "Naam : ".$show2[artiesten]."
";
echo "Woonplaats : ".$show2[woonplaats]."
";
echo "Totaal : ".$tracks."
";

$titel = $show2[artiesten];

}

$track_select = mysql_query("

SELECT
id,
artiest,
titel
FROM
track
WHERE
artiesten = ".$_GET[rap]."
ORDER BY
id DESC

") or die(mysql_error());

$color = array( #ecd7a2, #e1c98b);
$i = 0;
if(!mysql_num_rows($track_select))
{

echo "Er zijn (nog) geen tracks van deze artiest.
";

}
else
{

echo "

";
while ($show = mysql_fetch_assoc($track_select))
{

$show[artiest] = stripslashes($show[artiest]);
$show[artiest] = htmlentities($show[artiest]);

$show[titel] = stripslashes($show[titel]);
$show[titel] = htmlentities($show[titel]);

echo "
";
if( $i > 0 )
{

$i = 0;

}
else
{

$i++;

}
}
echo "
".$show[artiest]." - ".$show[titel]."

";
}

}
mysql_close();
?>
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rap[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rap[/COLOR][COLOR= #007700]]);[/COLOR]

[COLOR= #0000BB]$rap_select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"

    SELECT
        id,
        artiesten,
        woonplaats
    FROM
        artiesten
    WHERE
        id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rap[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"
    ORDER BY
        artiesten ASC
        
"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rap_select[/COLOR][COLOR= #007700]))
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Deze artiest bestaat niet."[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR] 

    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$show2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rap_select[/COLOR][COLOR= #007700]))
    {[/COLOR]
        
        [COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiesten[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiesten[/COLOR][COLOR= #007700]]);[/COLOR]
        [COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiesten[/COLOR][COLOR= #007700]] =[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiesten[/COLOR][COLOR= #007700]]);[/COLOR]
        [COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woonplaats[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woonplaats[/COLOR][COLOR= #007700]]);[/COLOR]
        [COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woonplaats[/COLOR][COLOR= #007700]] =[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woonplaats[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$tracks[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(1) FROM track WHERE artiesten="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]),[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]);[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Naam : "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiesten[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Woonplaats : "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woonplaats[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Totaal : "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$tracks[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];[/COLOR]
        
        [COLOR= #0000BB]$titel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$show2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiesten[/COLOR][COLOR= #007700]];
    
    }[/COLOR]

    [COLOR= #0000BB]$track_select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
    
        SELECT 
            id,
            artiest,
            titel 
        FROM 
            track 
        WHERE 
            artiesten = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rap[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" 
        ORDER BY 
            id DESC
    
    "[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    
    [COLOR= #0000BB]$color[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR] [COLOR= #DD0000]#ecd7a2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]#e1c98b[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$track_select[/COLOR][COLOR= #007700]))
    {[/COLOR]
    
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er zijn (nog) geen tracks van deze artiest.<br />"[/COLOR][COLOR= #007700];
    
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
    
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<p><table width="60%" cellpadding="0" cellspacing="0">"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$show[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$track_select[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]]);[/COLOR]
            [COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]] =[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]]);[/COLOR]
            
            [COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
            [COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]] =[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td style=background-color: "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$color[/COLOR][COLOR= #007700][[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]] .[/COLOR][COLOR= #DD0000]"><a href="index.php?pagina=track&track="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"">"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" - "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"</a></td>
            </td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700])
            {[/COLOR]
            
                [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];
            
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
            
                [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;
            
            }
        }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table></p>"[/COLOR][COLOR= #007700];
    }

    
}[/COLOR]
[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]();[/COLOR]
?>


maak dat ervan
0
Admir

Lid · Topicstarter

Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thanks sjoerd hij werkt!
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren