[PHP] Vragentopic JosNL

Gestart doorJosnl24 reacties53 weergaven

25 berichten · pagina 1 van 2

Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heey allemaal!

Ik heb een heel klein probleempje, nja, niet echt een probleem maar meer een schoonheidsfoutje.

Ik gebruik namelijk de date() functie om de datum + tijd van plaatsing in de database te zetten, alleen gaat dat in de verkeerde volgorde...

Ik heb nu dit:

[COLOR= #0000BB]<?php

$datum_db[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"F j, g:i"[/COLOR][COLOR= #007700]);[/COLOR]

?>


En dat geeft in de database dit weer:
2010-10-18 13:57:58

Terwijl het dit moet zijn:
18-10-2010 13:57:58

Iemand die mij kan vertellen welke letter ik toe moet voegen, of weg moet halen?

Alvast bedankt allemaal!

Gr.
Josshiny
PS: Er kunnen nog meer vragen komen.

==============================================================

PROBLEEM 2:

k zit nu met het volgende probleem:

Ik haal de gegevens, die ik eerder in de database heb geplaatst, uit de database op deze manier:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$resource[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `nieuws` ORDER BY `id` DESC"[/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_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resource[/COLOR][COLOR= #007700]))
{[/COLOR]
    [COLOR= #0000BB]$auteur[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]auteur[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$bericht_input[/COLOR] [COLOR= #007700]=[/COLOR] Ubb[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$bericht_titel[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datum[/COLOR][COLOR= #007700]];
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]

                                
                        <div class="bericht">
                                
                                <strong>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht_titel[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</strong>
                                
                                <font style="float: right; font-style: italic; padding-right: 15px;">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$datum[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] &nbsp;door: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$auteur[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</font>
                                
                        </div>
                        
                        <div class="bericht_content">
                        [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht_input[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
                        <br /><br />
                        
                        <font style="color: #b46a30; padding-bottom: 15px;">Lees meer &raquo;</font>
                        
                        </div>

                            </div>[/COLOR]


?>


Echter zit ik nu met het probleem dat ie maar 1 bericht laat zien, terwijl er meerdere in de database staan...

Ik hoop dat iemand mij hiermee kan helpen!biggrin
Gr.
Jos
0
Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php

$datum_db[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"j F, g:i"[/COLOR][COLOR= #007700]);[/COLOR]

?>


probeer dat eens
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Propje,

Helaas, dat werkt niet.nooo
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Je moet gewoon NOW() gebruiken.
INSERT INTO tabel (datumveld) VALUES (NOW())
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oeps, merk dat ik NOW() en $datum_db beide in de query had gezet...bloos
Maar met dat NOW() (wat ik normaal gebruik), krijg ik dit:
2010-10-18 14:36:19

Maar dat 2010-10-18 moet zijn 18-10-2010.
0
Berichten
545
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo?:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d-m-Y H:i:s"[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d-m-Y H:i:s"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/strtotime"]strtotime[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tijd_uit_database[/COLOR][COLOR= #007700]));[/COLOR]
?>
0
Berichten
545
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het gaat om de tijd van NU..
Dus de var $tijd_uit_database (TIMESTAMP) hoeft in dit geval niet.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je het uit de database haalt en echod moet je wel die code van mij gebruiken
0
Berichten
545
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan wel ja..
Verder moet die $tijd_uit_database wel met een TIMESTAMP eruit worden gehaald..

UNIX_TIMESTAMP(tijdcolumn) AS column
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom zou dat moeten? Gewoon tijdcolumn hoort ook al te werken
0
Berichten
545
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat wist ik niet..
Weer iets geleerd smile
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt voor de antwoorden allemaal!

Misschien dat er zometeen nog een paar vragen komen! yummie
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sorry voor het dubbelposten alvast, maar dit leek mij beter dan een nieuw topic te openen...bloos
Ik zit nu met het volgende probleem:

Ik haal de gegevens, die ik eerder in de database heb geplaatst, uit de database op deze manier:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$resource[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `nieuws` ORDER BY `id` DESC"[/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_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resource[/COLOR][COLOR= #007700]))
{[/COLOR]
    [COLOR= #0000BB]$auteur[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]auteur[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$bericht_input[/COLOR] [COLOR= #007700]=[/COLOR] Ubb[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$bericht_titel[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datum[/COLOR][COLOR= #007700]];
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]

                                
                        <div class="bericht">
                                
                                <strong>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht_titel[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</strong>
                                
                                <font style="float: right; font-style: italic; padding-right: 15px;">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$datum[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] &nbsp;door: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$auteur[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</font>
                                
                        </div>
                        
                        <div class="bericht_content">
                        [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht_input[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
                        <br /><br />
                        
                        <font style="color: #b46a30; padding-bottom: 15px;">Lees meer &raquo;</font>
                        
                        </div>

                            </div>[/COLOR]


?>


Echter zit ik nu met het probleem dat ie maar 1 bericht laat zien, terwijl er meerdere in de database staan...

Ik hoop dat iemand mij hiermee kan helpen!biggrin
Gr.
Jos
0
Berichten
545
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$resource[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `nieuws` ORDER BY `id` DESC"[/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_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resource[/COLOR][COLOR= #007700]))
{[/COLOR]
    [COLOR= #0000BB]$auteur[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]auteur[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$bericht_input[/COLOR] [COLOR= #007700]=[/COLOR] Ubb[COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$bericht_titel[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
    [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datum[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]

                                
                        <div class="bericht">
                                
                                <strong>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht_titel[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</strong>
                                
                                <font style="float: right; font-style: italic; padding-right: 15px;">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$datum[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] &nbsp;door: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$auteur[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</font>
                                
                        </div>
                        
                        <div class="bericht_content">
                        [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht_input[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
                        <br /><br />
                        
                        <font style="color: #b46a30; padding-bottom: 15px;">Lees meer &raquo;</font>
                        
                        </div>

                            </div>[/COLOR][COLOR= #007700];

}[/COLOR]
?>
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