Rushy Posted November 12, 2007 Share Posted November 12, 2007 Hey all, another quick question. I need to add a number to <book></book> every time this piece of code loops. I.e. <book1></book1> then <book2></book2> echo fwrite($file,"<customer><fname>$_GET[fName]</fname><lname>$_GET[lName]</lname><email>$_GET[Email]</email></customer>"); foreach($_COOKIE as $cookie){ echo fwrite($file, "<books><book>\"$cookie\"</book></books>"); } Could someone please tell me how to do this? I researched it but I can't seem to get it to work Link to comment https://forums.phpfreaks.com/topic/76932-solved-incrementing-in-a-loop/ Share on other sites More sharing options...
teng84 Posted November 12, 2007 Share Posted November 12, 2007 echo fwrite($file,"<customer><fname>$_GET[fName]</fname><lname>$_GET[lName]</lname><email>$_GET[Email]</email></customer>"); foreach($_COOKIE as $cookie){ ++$cnt;// set a counter echo fwrite($file, "<books".$cnt."><books".$cnt.">\"$cookie\"</books".$cnt."</books".$cnt.">"); } Link to comment https://forums.phpfreaks.com/topic/76932-solved-incrementing-in-a-loop/#findComment-389526 Share on other sites More sharing options...
Rushy Posted November 12, 2007 Author Share Posted November 12, 2007 Cheers!! Much appreciated. Link to comment https://forums.phpfreaks.com/topic/76932-solved-incrementing-in-a-loop/#findComment-389528 Share on other sites More sharing options...
teng84 Posted November 12, 2007 Share Posted November 12, 2007 youre welcome friend ! Link to comment https://forums.phpfreaks.com/topic/76932-solved-incrementing-in-a-loop/#findComment-389530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.