I'm looping out a lot of data to create tables, but after the loop has terminated at the bottom of the file I'm getting an EOF PHP error. This is kind of unique syntax, but I don't see a problem with the code. Here is the code (starting with the first foreach loop):
<div class="tbody">
<?php foreach ($extra_html['data'] as $referrers) { ?>
<div class="tr-container">
<div class="tr" data-referral-id="28401">
<div class="referral-data-container">
<span class="data blue referred-by"><?=$referrers['referrer']?></span>
<span class="data referral-number"><?=$referrers['referrals_made']?></span>
<span class="data blue qualified-number"><?=$referrers['referrals_qualified']?></span>
<span class="data sold-number green"><?=$referrers['referrals_sold']?></span>
<input type="text" value="$<?=$referrers['next_payout_amount']?>" class="data-input next-payout-amount input-widths" style="margin-right:25px;">
<input type="date" value="<?=($referrers['next_payout_date'] === '0' ? 'yyyy-MM-dd' : $referrers['next_payout_date'])?>" class="data-input next-payout-date input-widths" style="margin-right:25px;">
<input type="text" value="<?=$referrers['salesperson']?>" class="data-input salesperson input-widths">
</div>
<div class="plus-sign"></div>
</div>
<div class="nested-table">
<div class="nested-thead">
<div>
<span class="heading number-width">#</span>
<span class="heading referral-name-width">Referral</span>
<span class="heading referral-date-width">Referral Date</span>
<span class="heading status-width">Status</span>
<span class="heading checkboxes-width">Qualified Payout</span>
<span class="heading input-widths">Sold Payout</span>
</div>
</div>
<div class="nested-tbody">
<?php for ($i = 0; $i < count($referrers['referrals']); $i++) { ?>
<div class="nested-tr">
<span class="data number-width"><?=$i?></span>
<span class="data blue referral-name-width" onclick="showReferralModal(this)"><?=$referrers['referrals'][$i]['referral']?></span>
<span class="data referral-date-width"><?=$referrers['referrals'][$i]['date_added']?></span>
<div class="status-width">
<select>
<option selected>New Referral</option>
<option>Qualified Referral</option>
<option>DQ'd Referral</option>
<option>Sold Referral</option>
</select>
</div>
<div class="checkboxes-width">
<input type="checkbox" class="qualified-payout-checkbox blue">
</div>
<div class="checkboxes-width">
<input type="checkbox" class="sold-payout-checkbox blue">
</div>
</div>
<? } ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="modal-container">
<div class="white-box">
<div class="top">
<h3>Name Here</h3>
<div class="close" onclick="closeModal()"></div>
</div>
</div>
</div>
<script src="/js/referral.js"></script>
<?php include_once '../view/includes/footer_nav.php'; ?>
<?php include_once '../view/includes/footer.php'; ?>
To explain the unique syntax, I'm closing the first foreach loop three closing div tags (</div>
) after I'm closing the inner for loop. And the EOF error is coming after the last include_once
statement. I'm doing it this way so I can get syntax highlighting from my IDE (Sublime). I tried doing this syntax:
<?php foreach ($extra_html['data'] as $referrers): ?>
// html
<?php for ($i = 0; $i < count($referrers['referrals']); $i++): ?>
// more html
<?php endfor; ?>
// html
<?php endforeach; ?>
But I was getting an "unexpected foreach statement" error.
So I guess my question is kind of two fold:
How can I fix the EOF error with how I'm currently doing everything? And if the answer is no, what is the better way of doing this?