Versio

Fout in loop?

Overzicht Reageren

Bas Visscher

Bas Visscher

16/11/2009 13:53:00
Quote Anchor link
Hallo,

Hieronder de code, hij stopt bij 1 keer schrijven in de loop of waar?
Als ik zeg maar bij functie AlbMake(); in de while loop een 1 echo geeft hij die wel vaker weer dat zou ook moeten, omdat er meer in de database staat. maar waarom schrijft hij gewoon niet meer dan maar 1 album?

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

MaaknewAlb();

function
MaaknewAlb(){
include('../db/connectie.php');
$queryalb = "SELECT album FROM album WHERE album != 'voorpagina' ";
$albuit = mysql_query($queryalb)or die(mysql_error()."Fout bij aanmaken album.");
    while($alb = mysql_fetch_assoc($albuit)){
    AlbMake($alb['album']);
    }
}

function
AlbMake($alb){
include('../db/connectie.php');
$query = "SELECT * FROM foto WHERE album = '".$alb."'";
$xmldoc= "gallery.xml";
$fp=fopen($xmldoc,'w+');
fwrite($fp,"<?xml version=1.0 ?>\n");  
$foto = mysql_query($query)or die(mysql_error());
     fwrite($fp,"<category name=\"".$alb."\" >\n");
    while($fot = mysql_fetch_assoc($foto)){
    fwrite($fp,"<image>\n");
    fwrite($fp,"<date>2009</date>\n");
    fwrite($fp, "<title></title>\n");
    fwrite($fp,"<desc>".$fot['beschrijving']."</desc>\n");
    fwrite($fp, "<thumb>thumb_".$fot['naam']."</thumb>\n");
    fwrite($fp, "<img>".$fot['naam']."</img>\n");
    fwrite($fp, "</image>\n");
    }

    fwrite($fp,"</category>\n");
    fclose($fp);
}

?>


Output in gallery.xml:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?xml version=1.0 ?>
<category name="portretten" >
    <image>
        <date>2009</date>
        <title></title>
        <desc></desc>
        <thumb>thumb_7up_index.jpg</thumb>
        <img>7up_index.jpg</img>
    </image>
</category>
Gewijzigd op 01/01/1970 01:00:00 door Bas Visscher
 
PHP hulp

PHP hulp

24/05/2012 17:38:37
Gesponsorde koppelingen:
BHosted Hosting al vanaf € 1,- per maand

Controleer nu gratis jouw domeinnaam:

  
 
- SanThe -

- SanThe -

16/11/2009 14:02:00
Quote Anchor link
Je hebt hier al een topic over open staan.
 



Overzicht Reageren