Ik ben een top40 site aan het maken en ik kom bij een probleem.
ik ben nog niet zo goed met databases maar ik wil daar alles uit kunnen halen.
Nu heb ik dit stukje code:
<?php
$query = mysql_query("SELECT * FROM top40");
$row = mysql_fetch_array($query);

echo'
<p style="margin-left: 10px; margin-top: 5px; color: #FFFFFF; font-size: 14px; "><b><?php echo "Paginas: [1]"; ?></b><a href="top40-2.php" style="color: #FFFFFF;"><?php echo " 2"; ?></a><a href="top40-3.php" style="color: #FFFFFF;"><?php echo " 3"; ?></a><a href="top40-4.php" style="color: #FFFFFF;"><?php echo " 4"; ?></a><a href="top40-5.php" style="color: #FFFFFF;"><?php echo " 5"; ?></a></p>
<div id="top40background" style="margin-top: 10px;">
<img style="position: relative; margin-top: 13px; margin-left: 30px;" src='.$row['song_image'].' />
<div id="djsays" style="position: absolute; width: 140px; height: 5px; margin-top: -16px; margin-left: 29px;"><b></b><marquee style="float: right; width: 138px; color: #E244F4; margin-top: -3px;">Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - </marquee></div>
<p style="margin-left: 190px; margin-top: -150px; color: #FFFFFF; font-size: 25px; ">'.$row['song_artist'].'</p><br>
<p style="margin-left: 190px; margin-top: -40px; color: #E244F4; font-size: 20px; ">'.$row['song_name'].'</p><br>
<p><a style="margin-left: 195px; margin-top: -10px; color: #FFFFFF; font-size: 15px;" href='.$row['song_linkvideo'].' target="_blank">Bekijk Video</a><a style="margin-left: 23px; margin-top: -10px; color: #FFFFFF; font-size: 15px; " href='.$row['song_linkartist'].' target="_blank">Artiest Info</a></p>
<object type="application/x-shockwave-flash" width="299" height="25" style="margin-left: 190px; margin-top: 0px;" data='.$row['song_songplayer'].'><param name="movie" value='.$row['song_songplayer'].' /><param name="wmode" value="transparent" /></object>
</div>

<div id="top40background2">
<img style="position: relative; margin-top: 13px; margin-left: 30px;" src="../Public/Images/BigAlbums/calvinharris_wellbecomingback.png" />
<div id="djsays" style="position: absolute; width: 140px; height: 5px; margin-top: -16px; margin-left: 29px;"><b></b><marquee style="float: right; width: 138px; color: #E244F4; margin-top: -3px;">Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - Nieuw - </marquee></div>
<p style="margin-left: 190px; margin-top: -150px; color: #FFFFFF; font-size: 25px; " >'.$row['song_artist'].'</p><br>
<p style="margin-left: 190px; margin-top: -40px; color: #E244F4; font-size: 20px; " >'.$row['song_name'].'</p><br>
'
?>


Nu heb ik een tabel aangemaakt met id = 1 en dan de informatie.
Daar haalt hij alles uit. Maar ik nog een kolom aan met id = 2 dan krijg
ik bij het 2de gedeelte toch dezelfde informatie van id 1 en niet van id 2.
hoe kan ik het zo maken dat de ene .row kijkt bij id 1 en de andere .row kijkt bij id 2 enzo.
alvast bedankt
Regel 24:
echo 'Query is mislukt: '.$query;

Maak daarvan:
echo 'Query is mislukt: '.mysql_error();
Oke, Nu krijg ik in een keer dit:
Query is mislukt: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC' at line 4

En op lijn vier staat dat hij verwezen word naar het bestandje waarin hij connecteerd met de database.
En op lijn 62 staat dit met DESC:
LIMIT ".$start_id.", ".$aantal_rijen." DESC";

Alvast bedankt.
Nee, regel 4 in je query, niet in je php

[size=xsmall]Toevoeging op 06/08/2012 17:28:46:[/size]

DESC kan alleen in een ORDER BY, niet in een LIMIT clause
Jouw DESC staat achter LIMIT.

Het is ORDER BY ... DESC LIMIT ...
Huh, Wat moet ik doen?
Dit staat er:
$query = "
SELECT song_image, song_artist, song_name, song_songplayer
FROM top40
ORDER BY rang
LIMIT ".$start_id.", ".$aantal_rijen." DESC";
$query = "
SELECT song_image, song_artist, song_name, song_songplayer
FROM top40
ORDER BY rang DESC
LIMIT ".$start_id.", ".$aantal_rijen;
Hahaha er blijven steeds nieuwe errors komen.
Nu krijg ik dit:
Query is mislukt: Unknown column 'rang' in 'order clause'
Die moet duidelijk zijn.
Je hebt geen kolom met de naam 'rang' in de database blijkbaar.
Ik heb in de top40 tabel dit:
id, song_artist, song_name, song_image, song_linkartist, song_linkvideo, song_songplayer, song_new.
Dit is wat ik er in heb staan.
En ik heb id een primary key gegeven.
Dan kan je dus niet op 'rang' sorteren.
Verzin wat anders.

Reageren