1

I am following along the helloworld videos/tutorials on the joomla site and figured I would try displaying a table of numbers. I have been successful displaying the table as a whole but I would like to select several rows that are unique and can't sort our the proper way to get them to display.

to display the data I am using the following and it works perfectly.

<?php foreach ($this->items as $i => $item) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<?php echo $item->startdate; ?>
</td>
<td>
<?php echo $item->enddate; ?>
</td>

The table has 4 fields (besides all the usual joomla fields) "startdate, enddate, surname, special" of the 30 or so records 5 or 6 have a text note in the "special" field, is it possible to only display those rows?

Thanks for the help. Steve

0

Are these records with the text note the only records that have data in the special field? Not knowing what could potentially be in the special field, it is hard to determine a solution.

Solution 1 If the special field is empty apart from the records with the text note, then you could put a filter in your query, something like

WHERE special != ""
// Write the query appropriately

Solution 2 If the special field can have different text notes and you only want to display select records, you can simply add an if statement

<?php foreach ($this->items as $i => $item) : ?>
if ($item->special == "special text note") {
  <tr class="row<?php echo $i % 2; ?>">
  <td>
  <?php echo $item->startdate; ?>
  </td>
  <td>
  <?php echo $item->enddate; ?>
  </td>
}
  • Alex thank you for the suggestions. I tried solution 2 without success. The text in the special field can vary but generally it just says Total or a number and the word Total. I am going to try your solution 1 today and see if I can get modifying the query. Thanks again for the help. Steve – Steve C. Oct 24 '17 at 19:34
  • Also the records with the text in the special field are the only ones with any data in that field. – Steve C. Oct 24 '17 at 19:43
  • If all the other fields will be empty then solution 1 is definitely the way to go and only grab the data you need for the page. You should just be able to add WHERE special <> '' (single quotes, from what I understand safer than double quotes) to the query and get the desired results. – Alex Mehan Oct 24 '17 at 23:20
  • solution 1 worked perfectly was able to pull the data from the table. Thanks again for pointing me in the right direction. Steve – Steve C. Oct 25 '17 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.