We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10184
    • 5 Posts
    hi I have a small problem with a calender I’m making
    I have the honour to find out when you have a while loop in a snippet you cant print out the HTML in the correct, it only print the last cell out but it print it out the correct number of times

    see code
    snippet
    $i = 0;
    $accCalList = mysql_query("select * from accordion_agenda_cal where start >= '".date("Y-m-d")."' order by start asc");
    	while($accCalRow = mysql_fetch_array($accCalList)){
    				$i = $i + 1;
    				list($accCalyearS[$i], $accCalMonthS[$i], $accCalDayS[$i]) = explode("-",  $accCalRow[start]);
    				list($accCalyearE[$i], $accCalMonthE[$i], $accCalDayE[$i]) = explode("-",  $accCalRow[end]);
    				if($accCalz == 1){ $accCalz = 2; }else{ $accCalz = 1; }
    				#set all variables
    				$accCalTitle[$i] = $accCalRow[title];
    				$accCalCategory[$i] = $accCalRow[category];
    				$accCalDescription[$i] = $accCalRow[description];
    				#set place holders			
    				$modx->setPlaceholder('accCalyearS', $accCalyearS[$i]);
    				$modx->setPlaceholder('accCalMonthS', $accCalMonthS[$i]);
    				$modx->setPlaceholder('accCalDayS', $accCalDayS[$i]);
    				$modx->setPlaceholder('accCalyearE', $accCalyearE[$i]);
    				$modx->setPlaceholder('accCalMonthE', $accCalMonthE[$i]);
    				$modx->setPlaceholder('accCalDayE', $accCalDayE[$i]);
    				$modx->setPlaceholder('accCalTitle', $accCalTitle[$i]);
    				$modx->setPlaceholder('accCalCategory', $accCalCategory[$i]);
    				$modx->setPlaceholder('accCalDescription', $accCalDescription[$i]);
    				# write to chunck
    				$accCal[$i] = $modx->putChunk('AccordionCal');
    				echo $accCal[$i];
    				
    	};
    


    chunk named AccordionCal
    <li>
    	<div class='ui-accordion-left'></div>
    	<a class='ui-accordion-link acc1'><em>[+accCalDayS+]-[+accCalMonthS+]-[+accCalyearS+]</em> - <strong>[+accCalTitle+]</strong> - <em>[+accCalCategory+]</em>
    		<span class='ui-accordion-right'></span></a>
    	<div>
    		<em>[+accCalDayS+]-[+accCalMonthS+]-[+accCalyearS+] - [+accCalDayE+]-[+accCalMonthE+]-[+accCalyearE+]</em> <br>
    		<strong>[+accCalTitle+]</strong><br>
    		[+accCalDescription+] <br>
    	</div>
    </li>
    


    any help please
      • 4041
      • 788 Posts
      Have a look at this thread, it looks to be the same issue:
      http://modxcms.com/forums/index.php/topic,28874.msg175376.html#msg175376
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 4172
        • 5,888 Posts
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 3749
          • 24,544 Posts
          There’s only one placeholder with each name and your loop completes before anything is rendered for output, so all rows get the final value of each placeholder (hope that makes sense).

          One solution is to have an $output variable and add to it on each pass through the loop.

          $output = "";
          while( ...) {
          ...

          $output .= $accCal[$i];
          }

          return $output;




            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 10184
            • 5 Posts
            thanks for the help laugh