Styling van SQL output php

Gestart doorOne2xs9 reacties11 weergaven

10 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Ik heb een php pagina met de volgende code;

[COLOR= #0000BB]<?php 
$conn[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]localhost[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]databasenaam[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM tabel ORDER BY id DESC LIMIT 0,5"[/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]$x[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] 
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])) 
{[/COLOR] 
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$x[/COLOR][COLOR= #007700]+[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000])&nbsp;[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] - [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]nummer[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR] 
[COLOR= #0000BB]$x[/COLOR][COLOR= #007700]++; 
}[/COLOR] 
?>


Dit wordt weergeven als;


Quote:
1) Di-rect - Inside My Head
2) The Rolling Stones - Start Me Up
3) Adele - Set Fire To The Rain
4) Queen - Thank God Its Christmas
5) The Cardigans - My Favourite Game

Nou is het mijn bedoeling om het /ongeveer/ als volgt te krijgen;


Quote:
Di-rect - Inside My Head
_____________________________

The Rolling Stones - Start Me Up
_____________________________

Adele - Set Fire To The Rain
_____________________________

Queen - Thank God Its Christmas
_____________________________

The Cardigans - My Favourite Game

Kan iemand mij op weg helpen met de styling hiervan?
Was stiekem al trots dat er uberhaupt een output is gelukt biggrin
Alvast bedankt!
Justin

ps) even een blauwe kleur zodat het makkelijker onderscheiden kan worden smile
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Aan het eind
toevoegen aan elke regel?

toevoeging op 20 december 2012, 19:46:41:
dus achter
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Niet gek, dan krijg ik dit;
Afbeelding

Thanks!

Iemand een idee hoe ik die 0), 1), 2) etc. kan hiden?

toevoeging op 20 december 2012, 19:52:45:
Ik zie dat ik de rest van de styling via de css kan doen, dan smijt ik de output artiest/nummer
tussen een gestylde div smile
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
($x+1).) 

dit weghalen?
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Marvinguich schreef:
($x+1).) 

dit weghalen?
Hm, dit had ik al geprobeerd maar toen ik stukje voor stukje weg ging halen werkte het biggrinVoor anderen; dit is nu het stukje code;

echo .$row[artiest]. - .$row[nummer].<br /><br /><hr><br />;


toevoeging op 20 december 2012, 20:09:40:
Marvinguich thanks voor je input! Ik ga weer verder stoeien smile
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
No problem, en good luck!
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
echo $row[artiest]. - .$row[nummer].<br /><br /><hr /><br />;


En br kan je beter met CSS doen
0
Berichten
308
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
echo $row[artiest]. - .$row[nummer].<br /><br /><hr /><br />;
En br kan je beter met CSS doen

Inderdaad, je maakt veel beter een div en style deze met css i.p.v.
-tags te gebruiken.

VB.

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="track">[/COLOR][COLOR= #007700];[/COLOR]
      [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]artiest[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] - [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]nummer[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
?>


En dan style je .track met css, geef die een border en wat padding ofzo.
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bedankt voor alle tips, Robbeing ook! Dit ga ik na de feestdagen verwerken!
0
Berichten
308
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Livonias schreef:
Bedankt voor alle tips, Robbeing ook! Dit ga ik na de feestdagen verwerken!
Graag gedaan wink Succes nog wink
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