- Posts: 44
COMMUNITY FORUM
insert the function "foreach" in a table !
- Alaabouch
- Topic Author
- Offline
- Senior Member
Less
More
6 years 8 months ago #167312
by Alaabouch
insert the function "foreach" in a table ! was created by Alaabouch
Hello,
I had trouble inserting the "foreach" function into a table that displays data from the articles. can I have help ?
here is the code
the purpose of the function is to create a loop that displays a single array instead of several !
I had trouble inserting the "foreach" function into a table that displays data from the articles. can I have help ?
here is the code
<div class="itemContainer1 itemContainerLast" style="width:100.0%;">
<div class="responsive rt">
<table>
<thead>
<tr>
<th>Nom</th>
<th>Prix</th>
<th>Remboursement</th>
<th>Disponibilité</th>
</tr>
</thead>
<tbody>
<tr>
<td width="50%">
<?php if(isset($this->item->editLink)): ?>
<!-- Item edit link -->
<span class="catItemEditLink">
<a data-k2-modal="edit" href="<?php echo $this->item->editLink; ?>">
<?php echo JText::_('K2_EDIT_ITEM'); ?>
</a>
</span>
<?php endif; ?>
<h5 class="catItemView">
<?php if ($this->item->params->get('catItemTitleLinked')): ?>
<a href="<?php echo $this->item->link; ?>"><?php echo $this->item->title; ?></a>
<?php else: ?>
<?php echo $this->item->title; ?>
<?php endif; ?>
</h5>
</td>
<td width="20%"> <li><?php echo $this->item->extraFields->PPVDh->value ;?><?php echo $this->item->extraFields->Tlephone->value ;?></li> </td>
<td width="30%" align="center"> <li><?php echo $this->item->extraFields->Remboursement->value ;?><?php echo $this->item->extraFields->PVC->value ;?><?php echo $this->item->extraFields->Ville->value ;?></li></td>
<td width="30%" align="center"> <li><?php echo $this->item->extraFields->Disp->value ;?></li> </td>
</ul>
</tr>
</tbody>
</table>
</div>
</div>
the purpose of the function is to create a loop that displays a single array instead of several !
Please Log in or Create an account to join the conversation.
- Alaabouch
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
6 years 8 months ago - 6 years 8 months ago #167318
by Alaabouch
Replied by Alaabouch on topic insert the function "foreach" in a table !
Hi
I update....
medika.ma/medicamenta
I was able to insert the function but I had a loop of a table that repeats itself entirely to the number inserted in the box "Number of elements in header" (see attachment) :
how to get out of the loop
I update....
medika.ma/medicamenta
I was able to insert the function but I had a loop of a table that repeats itself entirely to the number inserted in the box "Number of elements in header" (see attachment) :
<div class="itemContainer1 itemContainerLast" style="width:100.0%;">
<div class="responsive rt">
<table>
<thead>
<tr>
<th>Nom</th>
<th>Prix</th>
<th>Remboursement</th>
<th>Disponibilité</th>
</tr>
</thead>
<tbody>
<?php foreach($this->leading as $this->item): ?>
<tr>
<td width="50%">
<?php if(isset($this->item->editLink)): ?>
<!-- Item edit link -->
<span class="catItemEditLink">
<a data-k2-modal="edit" href="<?php echo $this->item->editLink; ?>">
<?php echo JText::_('K2_EDIT_ITEM'); ?>
</a>
</span>
<?php endif; ?>
<h5 class="catItemView">
<?php if ($this->item->params->get('catItemTitleLinked')): ?>
<a href="<?php echo $this->item->link; ?>"><?php echo $this->item->title; ?></a>
<?php else: ?>
<?php echo $this->item->title; ?>
<?php endif; ?>
</h5>
</td>
<td width="20%"> <li><?php echo $this->item->extraFields->PPVDh->value ;?><?php echo $this->item->extraFields->Tlephone->value ;?></li> </td>
<td width="30%" align="center"> <li><?php echo $this->item->extraFields->Remboursement->value ;?><?php echo $this->item->extraFields->PVC->value ;?><?php echo $this->item->extraFields->Ville->value ;?></li></td>
<td width="30%" align="center"> <li><?php echo $this->item->extraFields->Disp->value ;?></li> </td>
</ul>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
how to get out of the loop
Last edit: 6 years 8 months ago by Alaabouch.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
6 years 7 months ago #167327
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic insert the function "foreach" in a table !
Hello,
The loop will be executed for as many leading items that are set in your category's settings.
You can break the loop by using PHP's break; php.net/manual/en/control-structures.break.php
The loop will be executed for as many leading items that are set in your category's settings.
You can break the loop by using PHP's break; php.net/manual/en/control-structures.break.php
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Alaabouch
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
6 years 7 months ago #167339
by Alaabouch
Replied by Alaabouch on topic insert the function "foreach" in a table !
Hi,
thank you for your attention, sincerely, I have not managed to break the loop correctly ! can you tell me where do I start ?
thank you for your attention, sincerely, I have not managed to break the loop correctly ! can you tell me where do I start ?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
6 years 7 months ago #167342
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic insert the function "foreach" in a table !
I am not sure what the issue is.
You need a foreach loop which prints all the leading items, there is no need to break the loop.
Use the HTML validator in order to identify any unclosed HTML tags which might break the layout.
You need a foreach loop which prints all the leading items, there is no need to break the loop.
Use the HTML validator in order to identify any unclosed HTML tags which might break the layout.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.