rrobertson1979 Posted March 6, 2007 Share Posted March 6, 2007 Hi! I am trying to get the following code to work. $recur = ""; $i = 0; if ($frequency == "weekly"){ $s = date('W', $startDate); do { echo "$s - "; $recur .= $s . "/"; $s = $s + 1; $i++; } while ($i <= 52);} echo $recur; I get the following output. 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 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 - 50 - 51 - 52 - 53 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 10 I don't understand why $recur does not print "10/11/12..." instead of "10". Any help is GREATLY appreciated!!!! Link to comment https://forums.phpfreaks.com/topic/41464-trouble-setting-variable-within-do_while-script/ Share on other sites More sharing options...
skali Posted March 6, 2007 Share Posted March 6, 2007 This code is working perfectly <?php $recur = ""; $i = 0; $frequency='weekly'; if ($frequency == "weekly"){ $s = date('W', time()); do { echo "$s - "; $recur .= $s . "/"; $s = $s + 1; $i++; } while ($i <= 52);} echo $recur; ?> Link to comment https://forums.phpfreaks.com/topic/41464-trouble-setting-variable-within-do_while-script/#findComment-200878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.